669ebfbec09b_add_cropcd_input_table.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """add_CropCd_input_table
  2. Revision ID: 669ebfbec09b
  3. Revises: 95832ecc0bdc
  4. Create Date: 2025-07-12 01:03:04.780668
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '669ebfbec09b'
  10. down_revision = '95832ecc0bdc'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. """升级数据库到当前版本"""
  15. # ### commands auto generated by Alembic - please adjust! ###
  16. op.create_table('CropCd_input_data',
  17. sa.Column('ID', sa.Integer(), autoincrement=True, nullable=False, comment='自增主键'),
  18. sa.Column('Farmland_ID', sa.Integer(), nullable=False, comment='关联农地ID'),
  19. sa.Column('Sample_ID', sa.Integer(), nullable=False, comment='关联样点ID'),
  20. sa.Column('002_0002IDW', sa.Float(), nullable=True, comment='粉粒组分(0.002~0.02mm)质量占比[%]'),
  21. sa.Column('02_002IDW', sa.Float(), nullable=True, comment='砂粒组分(0.02~0.2mm)质量占比[%]'),
  22. sa.Column('2_02IDW', sa.Float(), nullable=True, comment='石砾组分(>2mm)质量占比[%]'),
  23. sa.Column('AvaP', sa.Float(), nullable=True, comment='速效钾(mg/kg)(对应Soil_data.AvaK_IDW)'),
  24. sa.Column('AvaK_IDW', sa.Float(), nullable=True, comment='有效磷(mg/kg)(对应Soil_data.AvaP_IDW)'),
  25. sa.Column('SAvaK_IDW', sa.Float(), nullable=True, comment='缓效钾(mg/kg)'),
  26. sa.Column('TAl_IDW', sa.Float(), nullable=True, comment='全铝含量(%)'),
  27. sa.Column('TCa_IDW', sa.Float(), nullable=True, comment='全钙含量(%)'),
  28. sa.Column('TFe_IDW', sa.Float(), nullable=True, comment='全铁含量(%)'),
  29. sa.Column('TMg_IDW', sa.Float(), nullable=True, comment='全镁含量(%)'),
  30. sa.Column('TMn_IDW', sa.Float(), nullable=True, comment='全锰含量(mg/kg)'),
  31. sa.Column('TN_IDW', sa.Float(), nullable=True, comment='全氮含量(g/kg)'),
  32. sa.Column('TS_IDW', sa.Float(), nullable=True, comment='全硫含量(g/kg)'),
  33. sa.Column('solution', sa.Float(), nullable=True, comment='LN(POR_Layer/bd020_90 * 112000*Cd.solution)'),
  34. sa.ForeignKeyConstraint(['Farmland_ID', 'Sample_ID'], ['Farmland_data.Farmland_ID', 'Farmland_data.Sample_ID'], ),
  35. sa.PrimaryKeyConstraint('ID'),
  36. comment='作物镉预测模型输入数据'
  37. )
  38. # ### end Alembic commands ###
  39. def downgrade():
  40. """将数据库降级到上一版本"""
  41. # ### commands auto generated by Alembic - please adjust! ###
  42. op.drop_table('CropCd_input_data')
  43. # ### end Alembic commands ###