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 ###
72c21b8fa484_add_nationality_ethnicity_to_patient.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录