def upgrade():
# When making changes to a column that has a foreign key, we need to drop
# and then re-add the constraint
op.execute('DELETE FROM txn_reconciles WHERE txn_id IS NULL;')
op.execute('LOCK TABLES txn_reconciles WRITE, transactions WRITE;')
op.drop_constraint('fk_txn_reconciles_txn_id_transactions',
'txn_reconciles', type_='foreignkey')
op.alter_column(
'txn_reconciles',
'txn_id',
existing_type=mysql.INTEGER(display_width=11),
nullable=False
)
op.create_foreign_key('fk_txn_reconciles_txn_id_transactions',
'txn_reconciles', 'transactions', ['txn_id'], ['id'])
op.execute('UNLOCK TABLES;')
5446559aecf7_txnreconcile_txn_id_not_null.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录