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