12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- """add_assessment_table
- Revision ID: 2c8efb3e01d8
- Revises: 3f2e574cefad
- Create Date: 2025-07-12 00:30:29.455412
- """
- from alembic import op
- import sqlalchemy as sa
- # revision identifiers, used by Alembic.
- revision = '2c8efb3e01d8'
- down_revision = '3f2e574cefad'
- branch_labels = None
- depends_on = None
- def upgrade():
- """升级数据库到当前版本"""
- # ### commands auto generated by Alembic - please adjust! ###
- op.create_table('Assessment',
- sa.Column('ID', sa.Integer(), autoincrement=True, nullable=False, comment='自增主键'),
- sa.Column('Farmland_ID', sa.Integer(), nullable=False, comment='关联Farmland_data表的Farmland_ID'),
- sa.Column('Sample_ID', sa.Integer(), nullable=False, comment='关联Farmland_data表的Sample_ID'),
- sa.Column('Type', sa.Float(), nullable=True, comment='用地类型:旱地(0)、水田(1)、水浇地(2)'),
- sa.Column('IDW_2023SP_Cd', sa.Float(), nullable=True, comment='2023年三普Cd(mg/kg)'),
- sa.Column('IDW_2023SP_pH', sa.Float(), nullable=True, comment='2023年三普pH'),
- sa.Column('SOM_IDW', sa.Float(), nullable=True, comment='有机质(g/kg)'),
- sa.Column('安全生产风险阈值', sa.Float(), nullable=True, comment='安全生产风险阈值'),
- sa.Column('污染风险筛选值', sa.Float(), nullable=True, comment='污染风险筛选值'),
- 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('Assessment')
- # ### end Alembic commands ###
|