"""migration

Revision ID: 498bbf0b3be2
Revises: 
Create Date: 2025-09-15 10:09:29.906049

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '498bbf0b3be2'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('asset_router',
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('asset_type', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('sid')
    )
    op.create_table('dividend_payouts',
    sa.Column('index', sa.String(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('ex_date', sa.Date(), nullable=False),
    sa.Column('declared_date', sa.Date(), nullable=False),
    sa.Column('record_date', sa.Date(), nullable=False),
    sa.Column('pay_date', sa.Date(), nullable=False),
    sa.Column('amount', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('index')
    )
    op.create_index(op.f('ix_dividend_payouts_ex_date'), 'dividend_payouts', ['ex_date'], unique=False)
    op.create_index(op.f('ix_dividend_payouts_sid'), 'dividend_payouts', ['sid'], unique=False)
    op.create_table('dividends',
    sa.Column('index', sa.String(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('effective_date', sa.Date(), nullable=False),
    sa.Column('ratio', sa.Float(), nullable=False),
    sa.PrimaryKeyConstraint('index')
    )
    op.create_index(op.f('ix_dividends_effective_date'), 'dividends', ['effective_date'], unique=False)
    op.create_index(op.f('ix_dividends_sid'), 'dividends', ['sid'], unique=False)
    op.create_table('exchanges',
    sa.Column('exchange', sa.String(), nullable=False),
    sa.Column('canonical_name', sa.String(), nullable=False),
    sa.Column('country_code', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('exchange')
    )
    op.create_table('mergers',
    sa.Column('index', sa.String(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('effective_date', sa.Date(), nullable=False),
    sa.Column('ratio', sa.Float(), nullable=False),
    sa.PrimaryKeyConstraint('index')
    )
    op.create_index(op.f('ix_mergers_effective_date'), 'mergers', ['effective_date'], unique=False)
    op.create_index(op.f('ix_mergers_sid'), 'mergers', ['sid'], unique=False)
    op.create_table('splits',
    sa.Column('index', sa.String(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('effective_date', sa.Date(), nullable=False),
    sa.Column('ratio', sa.Float(), nullable=False),
    sa.PrimaryKeyConstraint('index')
    )
    op.create_index(op.f('ix_splits_effective_date'), 'splits', ['effective_date'], unique=False)
    op.create_index(op.f('ix_splits_sid'), 'splits', ['sid'], unique=False)
    op.create_table('stock_dividend_payouts',
    sa.Column('index', sa.String(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('ex_date', sa.Date(), nullable=False),
    sa.Column('declared_date', sa.Date(), nullable=False),
    sa.Column('record_date', sa.Date(), nullable=False),
    sa.Column('pay_date', sa.Date(), nullable=False),
    sa.Column('payment_sid', sa.String(), nullable=False),
    sa.Column('ration', sa.Float(), nullable=False),
    sa.PrimaryKeyConstraint('index')
    )
    op.create_index(op.f('ix_stock_dividend_payouts_ex_date'), 'stock_dividend_payouts', ['ex_date'], unique=False)
    op.create_index(op.f('ix_stock_dividend_payouts_sid'), 'stock_dividend_payouts', ['sid'], unique=False)
    op.create_table('symbols_universe',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('symbol', sa.String(), nullable=False),
    sa.Column('universe_type', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('commodities',
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('mic', sa.String(), nullable=True),
    sa.Column('asset_name', sa.String(), nullable=False),
    sa.Column('start_date', sa.Date(), nullable=False),
    sa.Column('end_date', sa.Date(), nullable=False),
    sa.Column('first_traded', sa.Date(), nullable=False),
    sa.Column('auto_close_date', sa.Date(), nullable=False),
    sa.ForeignKeyConstraint(['sid'], ['asset_router.sid'], ),
    sa.PrimaryKeyConstraint('sid')
    )
    op.create_table('currencies',
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('mic', sa.String(), nullable=True),
    sa.Column('asset_name', sa.String(), nullable=False),
    sa.Column('start_date', sa.Date(), nullable=False),
    sa.Column('end_date', sa.Date(), nullable=False),
    sa.Column('first_traded', sa.Date(), nullable=False),
    sa.Column('auto_close_date', sa.Date(), nullable=False),
    sa.ForeignKeyConstraint(['sid'], ['asset_router.sid'], ),
    sa.PrimaryKeyConstraint('sid')
    )
    op.create_table('equities',
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('mic', sa.String(), nullable=True),
    sa.Column('asset_name', sa.String(), nullable=False),
    sa.Column('start_date', sa.Date(), nullable=False),
    sa.Column('end_date', sa.Date(), nullable=False),
    sa.Column('first_traded', sa.Date(), nullable=False),
    sa.Column('auto_close_date', sa.Date(), nullable=False),
    sa.ForeignKeyConstraint(['sid'], ['asset_router.sid'], ),
    sa.PrimaryKeyConstraint('sid')
    )
    op.create_table('futures_root_symbols',
    sa.Column('root_symbol', sa.String(), nullable=False),
    sa.Column('root_symbol_id', sa.Integer(), nullable=False),
    sa.Column('sector', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=False),
    sa.Column('exchange', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['exchange'], ['exchanges.exchange'], ),
    sa.PrimaryKeyConstraint('root_symbol')
    )
    op.create_index(op.f('ix_futures_root_symbols_exchange'), 'futures_root_symbols', ['exchange'], unique=False)
    op.create_table('symbols_universe_assets',
    sa.Column('symbol_universe_id', sa.Integer(), nullable=False),
    sa.Column('asset_sid', sa.Integer(), nullable=False),
    sa.Column('ratio', sa.Numeric(precision=12, scale=8), nullable=True),
    sa.ForeignKeyConstraint(['asset_sid'], ['asset_router.sid'], ),
    sa.ForeignKeyConstraint(['symbol_universe_id'], ['symbols_universe.id'], ),
    sa.PrimaryKeyConstraint('symbol_universe_id', 'asset_sid')
    )
    op.create_table('currency_symbol_mappings',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('symbol', sa.String(), nullable=False),
    sa.Column('start_date', sa.Date(), nullable=False),
    sa.Column('end_date', sa.Date(), nullable=False),
    sa.Column('exchange', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['exchange'], ['exchanges.exchange'], ),
    sa.ForeignKeyConstraint(['sid'], ['currencies.sid'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_currency_symbol_mappings_exchange'), 'currency_symbol_mappings', ['exchange'], unique=False)
    op.create_index(op.f('ix_currency_symbol_mappings_sid'), 'currency_symbol_mappings', ['sid'], unique=False)
    op.create_table('equity_supplementary_mappings',
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('field', sa.String(), nullable=False),
    sa.Column('start_date', sa.Date(), nullable=False),
    sa.Column('end_date', sa.Date(), nullable=False),
    sa.Column('value', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['sid'], ['equities.sid'], ),
    sa.PrimaryKeyConstraint('sid', 'field', 'start_date')
    )
    op.create_index(op.f('ix_equity_supplementary_mappings_end_date'), 'equity_supplementary_mappings', ['end_date'], unique=False)
    op.create_index(op.f('ix_equity_supplementary_mappings_field'), 'equity_supplementary_mappings', ['field'], unique=False)
    op.create_index(op.f('ix_equity_supplementary_mappings_sid'), 'equity_supplementary_mappings', ['sid'], unique=False)
    op.create_index(op.f('ix_equity_supplementary_mappings_start_date'), 'equity_supplementary_mappings', ['start_date'], unique=False)
    op.create_table('equity_symbol_mappings',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('symbol', sa.String(), nullable=False),
    sa.Column('company_symbol', sa.String(), nullable=False),
    sa.Column('share_class_symbol', sa.String(), nullable=False),
    sa.Column('start_date', sa.Date(), nullable=False),
    sa.Column('end_date', sa.Date(), nullable=False),
    sa.Column('exchange', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['exchange'], ['exchanges.exchange'], ),
    sa.ForeignKeyConstraint(['sid'], ['equities.sid'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_equity_symbol_mappings_company_symbol'), 'equity_symbol_mappings', ['company_symbol'], unique=False)
    op.create_index(op.f('ix_equity_symbol_mappings_exchange'), 'equity_symbol_mappings', ['exchange'], unique=False)
    op.create_index(op.f('ix_equity_symbol_mappings_sid'), 'equity_symbol_mappings', ['sid'], unique=False)
    op.create_table('futures_contracts',
    sa.Column('symbol', sa.String(), nullable=False),
    sa.Column('root_symbol', sa.String(), nullable=False),
    sa.Column('notice_date', sa.Date(), nullable=False),
    sa.Column('expiration_date', sa.Date(), nullable=False),
    sa.Column('multiplier', sa.Float(), nullable=False),
    sa.Column('tick_size', sa.Float(), nullable=False),
    sa.Column('exchange', sa.String(), nullable=False),
    sa.Column('sid', sa.Integer(), nullable=False),
    sa.Column('mic', sa.String(), nullable=True),
    sa.Column('asset_name', sa.String(), nullable=False),
    sa.Column('start_date', sa.Date(), nullable=False),
    sa.Column('end_date', sa.Date(), nullable=False),
    sa.Column('first_traded', sa.Date(), nullable=False),
    sa.Column('auto_close_date', sa.Date(), nullable=False),
    sa.ForeignKeyConstraint(['exchange'], ['exchanges.exchange'], ),
    sa.ForeignKeyConstraint(['root_symbol'], ['futures_root_symbols.root_symbol'], ),
    sa.ForeignKeyConstraint(['sid'], ['asset_router.sid'], ),
    sa.PrimaryKeyConstraint('sid'),
    sa.UniqueConstraint('symbol')
    )
    op.create_index(op.f('ix_futures_contracts_exchange'), 'futures_contracts', ['exchange'], unique=False)
    op.create_index(op.f('ix_futures_contracts_root_symbol'), 'futures_contracts', ['root_symbol'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_futures_contracts_root_symbol'), table_name='futures_contracts')
    op.drop_index(op.f('ix_futures_contracts_exchange'), table_name='futures_contracts')
    op.drop_table('futures_contracts')
    op.drop_index(op.f('ix_equity_symbol_mappings_sid'), table_name='equity_symbol_mappings')
    op.drop_index(op.f('ix_equity_symbol_mappings_exchange'), table_name='equity_symbol_mappings')
    op.drop_index(op.f('ix_equity_symbol_mappings_company_symbol'), table_name='equity_symbol_mappings')
    op.drop_table('equity_symbol_mappings')
    op.drop_index(op.f('ix_equity_supplementary_mappings_start_date'), table_name='equity_supplementary_mappings')
    op.drop_index(op.f('ix_equity_supplementary_mappings_sid'), table_name='equity_supplementary_mappings')
    op.drop_index(op.f('ix_equity_supplementary_mappings_field'), table_name='equity_supplementary_mappings')
    op.drop_index(op.f('ix_equity_supplementary_mappings_end_date'), table_name='equity_supplementary_mappings')
    op.drop_table('equity_supplementary_mappings')
    op.drop_index(op.f('ix_currency_symbol_mappings_sid'), table_name='currency_symbol_mappings')
    op.drop_index(op.f('ix_currency_symbol_mappings_exchange'), table_name='currency_symbol_mappings')
    op.drop_table('currency_symbol_mappings')
    op.drop_table('symbols_universe_assets')
    op.drop_index(op.f('ix_futures_root_symbols_exchange'), table_name='futures_root_symbols')
    op.drop_table('futures_root_symbols')
    op.drop_table('equities')
    op.drop_table('currencies')
    op.drop_table('commodities')
    op.drop_table('symbols_universe')
    op.drop_index(op.f('ix_stock_dividend_payouts_sid'), table_name='stock_dividend_payouts')
    op.drop_index(op.f('ix_stock_dividend_payouts_ex_date'), table_name='stock_dividend_payouts')
    op.drop_table('stock_dividend_payouts')
    op.drop_index(op.f('ix_splits_sid'), table_name='splits')
    op.drop_index(op.f('ix_splits_effective_date'), table_name='splits')
    op.drop_table('splits')
    op.drop_index(op.f('ix_mergers_sid'), table_name='mergers')
    op.drop_index(op.f('ix_mergers_effective_date'), table_name='mergers')
    op.drop_table('mergers')
    op.drop_table('exchanges')
    op.drop_index(op.f('ix_dividends_sid'), table_name='dividends')
    op.drop_index(op.f('ix_dividends_effective_date'), table_name='dividends')
    op.drop_table('dividends')
    op.drop_index(op.f('ix_dividend_payouts_sid'), table_name='dividend_payouts')
    op.drop_index(op.f('ix_dividend_payouts_ex_date'), table_name='dividend_payouts')
    op.drop_table('dividend_payouts')
    op.drop_table('asset_router')
    # ### end Alembic commands ###
