def downgrade(pyramid_env):
schema, user = config.get('db_schema'), config.get('db_user')
with context.begin_transaction():
for tablename in tables:
index_name = "%s_%s_%s_UNQC_base_id_tombstone_date" % (
schema, user, tablename)
op.drop_constraint(index_name, tablename, schema=schema)
op.add_column(tablename, sa.Column('is_tombstone', sa.SmallInteger, server_default="0"))
# repopulate is_tombstone
with transaction.manager:
for tablename in tables:
op.execute('UPDATE %s set "is_tombstone" = (CASE WHEN "tombstone_date" IS NULL THEN 0 ELSE 1 END)' % (tablename,))
mark_changed()
with context.begin_transaction():
for tablename in tables:
op.drop_column(tablename, "base_id")
op.drop_column(tablename, "tombstone_date")
op.drop_table(tablename+ID_TABLE)
op.execute('ALTER TABLE %s ADD CHECK ("is_tombstone" IN (0, 1))'%(tablename,))
368a596ab4b5_tombstone_date.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录