kopia lustrzana https://github.com/bugout-dev/moonstream
commit
4599c4b581
|
@ -0,0 +1,51 @@
|
|||
"""fix indexes
|
||||
|
||||
Revision ID: 42ca451a9c33
|
||||
Revises: 2fa541f6f6fc
|
||||
Create Date: 2022-06-07 13:30:40.746341
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "42ca451a9c33"
|
||||
down_revision = "2fa541f6f6fc"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(
|
||||
"ix_polygon_labels_address_label_label_data_type_and_name",
|
||||
table_name="polygon_labels",
|
||||
)
|
||||
op.create_index(
|
||||
"ix_polygon_labels_address_block_number",
|
||||
"polygon_labels",
|
||||
["address", "block_number"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
"ix_polygon_labels_address_block_timestamp",
|
||||
"polygon_labels",
|
||||
["address", "block_timestamp"],
|
||||
unique=False,
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute(
|
||||
"""
|
||||
CREATE INDEX ix_polygon_labels_address_label_label_data_type_and_name ON polygon_labels USING BTREE (address,label,(label_data->>'type'),(label_data->>'name'));
|
||||
"""
|
||||
)
|
||||
op.drop_index(
|
||||
"ix_polygon_labels_address_block_timestamp", table_name="polygon_labels"
|
||||
)
|
||||
op.drop_index("ix_polygon_labels_address_block_number", table_name="polygon_labels")
|
||||
# ### end Alembic commands ###
|
|
@ -5,6 +5,7 @@ from sqlalchemy import (
|
|||
BigInteger,
|
||||
Column,
|
||||
DateTime,
|
||||
Index,
|
||||
Integer,
|
||||
ForeignKey,
|
||||
MetaData,
|
||||
|
@ -230,6 +231,21 @@ class PolygonLabel(Base): # type: ignore
|
|||
|
||||
__tablename__ = "polygon_labels"
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"ix_polygon_labels_address_block_number",
|
||||
"address",
|
||||
"block_number",
|
||||
unique=False,
|
||||
),
|
||||
Index(
|
||||
"ix_polygon_labels_address_block_timestamp",
|
||||
"address",
|
||||
"block_timestamp",
|
||||
unique=False,
|
||||
),
|
||||
)
|
||||
|
||||
id = Column(
|
||||
UUID(as_uuid=True),
|
||||
primary_key=True,
|
||||
|
@ -260,15 +276,6 @@ class PolygonLabel(Base): # type: ignore
|
|||
DateTime(timezone=True), server_default=utcnow(), nullable=False
|
||||
)
|
||||
|
||||
# Undescribed indexes
|
||||
"""
|
||||
Migration: alembic\versions\5f5b8f19570f_added_index_for_address_type_and_name_.py
|
||||
|
||||
Index: "ix_polygon_labels_address_label_label_data_type_and_name" created manually.
|
||||
By fields: (address, label, (label_data->>'type'), (label_data->>'name'))
|
||||
Reason: https://github.com/sqlalchemy/alembic/issues/469#issuecomment-441887478
|
||||
"""
|
||||
|
||||
|
||||
class XDaiBlock(Base): # type: ignore
|
||||
__tablename__ = "xdai_blocks"
|
||||
|
|
Ładowanie…
Reference in New Issue