@downgrades(3)
def _downgrade_v3(op):
 op.create_table('_new_equities', sa.Column('sid', sa.Integer, unique=True, nullable=False, primary_key=True), sa.Column('symbol', sa.Text), sa.Column('company_symbol', sa.Text), sa.Column('share_class_symbol', sa.Text), sa.Column('fuzzy_symbol', sa.Text), sa.Column('asset_name', sa.Text), sa.Column('start_date', sa.Integer, default=0, nullable=False), sa.Column('end_date', sa.Integer, nullable=False), sa.Column('first_traded', sa.Integer, nullable=False), sa.Column('auto_close_date', sa.Integer), sa.Column('exchange', sa.Text))
 op.execute('\n        insert into _new_equities\n        select * from equities\n        where equities.first_traded is not null\n        ')
 op.drop_table('equities')
 op.rename_table('_new_equities', 'equities')
 op.create_index('ix_equities_company_symbol', 'equities', ['company_symbol'])
 op.create_index('ix_equities_fuzzy_symbol', 'equities', ['fuzzy_symbol'])

@ downgrades ( 3 ) def _downgrade_v3 ( op ) : op . create_table ( '_new_equities' , sa . Column ( 'sid' , sa . Integer , unique = True , nullable = False , primary_key = True ) , sa . Column ( 'symbol' , sa . Text ) , sa . Column ( 'company_symbol' , sa . Text ) , sa . Column ( 'share_class_symbol' , sa . Text ) , sa . Column ( 'fuzzy_symbol' , sa . Text ) , sa . Column ( 'asset_name' , sa . Text ) , sa . Column ( 'start_date' , sa . Integer , default = 0 , nullable = False ) , sa . Column ( 'end_date' , sa . Integer , nullable = False ) , sa . Column ( 'first_traded' , sa . Integer , nullable = False ) , sa . Column ( 'auto_close_date' , sa . Integer ) , sa . Column ( 'exchange' , sa . Text ) ) op . execute ( '\n        insert into _new_equities\n        select * from equities\n        where equities.first_traded is not null\n        ' ) op . drop_table ( 'equities' ) op . rename_table ( '_new_equities' , 'equities' ) op . create_index ( 'ix_equities_company_symbol' , 'equities' , [ 'company_symbol' ] ) op . create_index ( 'ix_equities_fuzzy_symbol' , 'equities' , [ 'fuzzy_symbol' ] )
downgrade assets db by adding a not null constraint on equities .