45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
"""BlockIndex
|
|
|
|
Revision ID: ee22683693a5
|
|
Revises: 516b55c83144
|
|
Create Date: 2024-07-19 18:52:04.933167
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import dexorder.database
|
|
import dexorder.database.column_types
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'ee22683693a5'
|
|
down_revision: Union[str, None] = '516b55c83144'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('dbblock',
|
|
sa.Column('chain', dexorder.database.column_types.Blockchain(), nullable=False),
|
|
sa.Column('hash', postgresql.BYTEA(), nullable=False),
|
|
sa.Column('height', sa.Integer(), nullable=False),
|
|
sa.Column('timestamp', sa.INTEGER(), nullable=False),
|
|
sa.Column('confirmed', sa.Boolean(), nullable=False),
|
|
sa.Column('data', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
|
sa.PrimaryKeyConstraint('chain', 'hash')
|
|
)
|
|
op.create_index(op.f('ix_dbblock_height'), 'dbblock', ['height'], unique=False)
|
|
op.create_index(op.f('ix_dbblock_timestamp'), 'dbblock', ['timestamp'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_dbblock_timestamp'), table_name='dbblock')
|
|
op.drop_index(op.f('ix_dbblock_height'), table_name='dbblock')
|
|
op.drop_table('dbblock')
|
|
# ### end Alembic commands ###
|