from __future__ import annotations

from alembic import op
import sqlalchemy as sa

revision = "202607110002"
down_revision = "202607110001"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column("validations", sa.Column("revalidation_interval_months", sa.Integer(), nullable=False, server_default="24"))
    op.add_column("validations", sa.Column("next_validation_manually_overridden", sa.Boolean(), nullable=False, server_default=sa.false()))
    op.add_column("validations", sa.Column("version", sa.Integer(), nullable=False, server_default="1"))
    op.add_column("validations", sa.Column("previous_validation_id", sa.String(), nullable=True))
    op.create_foreign_key("fk_validations_previous_validation_id_validations", "validations", "validations", ["previous_validation_id"], ["id"])


def downgrade() -> None:
    op.drop_constraint("fk_validations_previous_validation_id_validations", "validations", type_="foreignkey")
    op.drop_column("validations", "previous_validation_id")
    op.drop_column("validations", "version")
    op.drop_column("validations", "next_validation_manually_overridden")
    op.drop_column("validations", "revalidation_interval_months")
