"""add_client_ip_to_scenarios

Revision ID: dc16c36e4373
Revises: 0001
Create Date: 2026-04-28 14:41:57.756341

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'dc16c36e4373'
down_revision = '0001'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('graft_combinations', 'stress_tolerance_override',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=False)
    op.alter_column('plants', 'disease_resistance',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=False)
    op.alter_column('plants', 'nutrient_uptake_efficiency',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=False)
    op.alter_column('scenario_results', 'risk_factors',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=False)
    op.alter_column('scenario_results', 'recommended_adjustments',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=False)
    op.alter_column('scenario_results', 'growth_timeline',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=False)
    op.add_column('scenarios', sa.Column('client_ip', sa.String(length=45), nullable=True))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('scenarios', 'client_ip')
    op.alter_column('scenario_results', 'growth_timeline',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=True)
    op.alter_column('scenario_results', 'recommended_adjustments',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=True)
    op.alter_column('scenario_results', 'risk_factors',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=True)
    op.alter_column('plants', 'nutrient_uptake_efficiency',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=True)
    op.alter_column('plants', 'disease_resistance',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=True)
    op.alter_column('graft_combinations', 'stress_tolerance_override',
               existing_type=postgresql.JSON(astext_type=sa.Text()),
               nullable=True)
    # ### end Alembic commands ###
