f757f77a81ca_add_msm_input_table.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """add_MSM_input_table
  2. Revision ID: f757f77a81ca
  3. Revises: 2c8efb3e01d8
  4. Create Date: 2025-07-12 00:40:46.128653
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = 'f757f77a81ca'
  10. down_revision = '2c8efb3e01d8'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. """升级数据库到当前版本"""
  15. # ### commands auto generated by Alembic - please adjust! ###
  16. op.create_table('MSM_input_data',
  17. sa.Column('ID', sa.Integer(), autoincrement=True, nullable=False),
  18. sa.Column('Farmland_ID', sa.Integer(), nullable=False),
  19. sa.Column('Sample_ID', sa.Integer(), nullable=False),
  20. sa.Column('Var', sa.String(length=20), nullable=False, comment='过程模型数据索引符'),
  21. sa.Column('CO2_g_tot', sa.Float(), nullable=False, comment='二氧化碳全量值'),
  22. sa.Column('watervolume', sa.Float(), nullable=True, comment='土壤水体积[cm³/cm³] = Soil_data.POR_Layer'),
  23. sa.Column('SL', sa.Float(), nullable=True, comment='固液比 = (1-POR_Layer)*bd020_90/(POR_Layer*1)'),
  24. sa.Column('pH', sa.Float(), nullable=True, comment='pH值(实测或Soil_data中IDW_*_pH三者之一)'),
  25. sa.Column('Ca_plus2_tot', sa.Float(), nullable=True, comment='总游离钙 = ExCa_IDW*0.005/(POR_Layer/bd020_90)'),
  26. sa.Column('Mg_plus2_tot', sa.Float(), nullable=True, comment='总游离镁 = ExMg_IDW*0.005/(POR_Layer/bd020_90)'),
  27. sa.Column('K_plus_tot', sa.Float(), nullable=True, comment='总游离钾 = ExK_IDW*0.005/(POR_Layer/bd020_90)'),
  28. sa.Column('Na_plus_tot', sa.Float(), nullable=True, comment='总游离钠 = ExNa_IDW*0.005/(POR_Layer/bd020_90)'),
  29. sa.Column('Cl_minus_tot', sa.Float(), nullable=True, comment='总游离氯 = (Ca_tot+Mg_tot)*2 + K_tot + Na_tot'),
  30. sa.Column('Cd_tot', sa.Float(), nullable=True, comment='总游离镉 = Cd/112000/(POR_Layer/bd020_90)'),
  31. sa.Column('HFO_kgkg', sa.Float(), nullable=True, comment='不定型铁 = Fed_IDW/1000 + ExAl_IDW*0.00009'),
  32. sa.Column('CLAY_kgkg', sa.Float(), nullable=True, comment='粘土矿物 = Soil_data.0002IDW'),
  33. sa.Column('HA_kgkg', sa.Float(), nullable=True, comment='活性胡敏酸 = SOM_IDW/1724*F1*F2'),
  34. sa.Column('FA_kgkg', sa.Float(), nullable=True, comment='活性富里酸 = SOM_IDW/1724*F1*(1-F2)'),
  35. sa.ForeignKeyConstraint(['Farmland_ID', 'Sample_ID'], ['Farmland_data.Farmland_ID', 'Farmland_data.Sample_ID'], ),
  36. sa.PrimaryKeyConstraint('ID'),
  37. comment='络合模型输入数据模型'
  38. )
  39. # ### end Alembic commands ###
  40. def downgrade():
  41. """将数据库降级到上一版本"""
  42. # ### commands auto generated by Alembic - please adjust! ###
  43. op.drop_table('MSM_input_data')
  44. # ### end Alembic commands ###