block cache uses db; alembic upgrade

This commit is contained in:
tim
2024-07-19 18:58:29 -04:00
parent 95d94e8d60
commit 8389fd2078
6 changed files with 126 additions and 31 deletions

View File

@@ -0,0 +1,44 @@
"""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 ###