def upgrade():
op.add_column('instance', sa.Column('created_by', mysql.VARCHAR(collation='utf8_bin', length=64), nullable=False))
op.add_column('instance', sa.Column('created_at', sa.DateTime(), nullable=False))
op.add_column('instance', sa.Column('updated_by', mysql.VARCHAR(collation='utf8_bin', length=64), nullable=False))
op.add_column('instance', sa.Column('updated_at', sa.DateTime(), nullable=False))
op.execute("""
UPDATE instance JOIN (
SELECT instance_id, min(created) min_created, max(created) max_created, author
FROM log
GROUP BY instance_id, author
) log
ON id = instance_id
SET created_at = min_created, created_by = author,
updated_at = max_created, updated_by = author
""")
c9b74509755e_add_created_and_modified_fields_to_.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录