72c21b8fa484_add_nationality_ethnicity_to_patient.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:radar 作者: renalreg 项目源码 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('patient_demographics', sa.Column('ethnicity_id', sa.Integer(), nullable=True))
    op.add_column('patient_demographics', sa.Column('nationality_id', sa.Integer(), nullable=True))
    op.execute('update patient_demographics set ethnicity_id = (select id from ethnicities where code = ethnicity)')
    op.create_foreign_key(
        'patient_demographics_ethnicity_id_fkey',
        'patient_demographics',
        'ethnicities',
        ['ethnicity_id'],
        ['id']
    )
    op.create_foreign_key(
        'patient_demographics_nationality_id_fkey',
        'patient_demographics',
        'nationalities',
        ['nationality_id'],
        ['id']
    )
    op.drop_column('patient_demographics', 'ethnicity')
    # ### end Alembic commands ###
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号