"""Create the immutable generation profile registry table.""" from __future__ import annotations import sqlalchemy as sa from alembic import op revision = "0013_generation_profiles" down_revision = "0012_profile_activations" branch_labels = None depends_on = None def upgrade() -> None: op.execute(sa.text("CREATE SCHEMA IF NOT EXISTS models")) op.create_table( "generation_profiles", sa.Column("id", sa.Uuid(), primary_key=True), sa.Column("profile", sa.String(64), nullable=False), sa.Column("version", sa.String(64), nullable=False), sa.Column("provider", sa.String(32), nullable=False), sa.Column("model_identifier", sa.String(128), nullable=False), sa.Column("model_digest", sa.String(128), nullable=False), sa.Column("context_limit", sa.Integer(), nullable=False), sa.Column("max_output_tokens", sa.Integer(), nullable=False), sa.Column("temperature", sa.Float(), nullable=False), sa.Column("data_policy", sa.String(32), nullable=False), sa.Column("timeout_seconds", sa.Float(), nullable=False), sa.Column("max_retries", sa.Integer(), nullable=False), sa.Column("active", sa.Boolean(), nullable=False, server_default=sa.text("false")), sa.Column("created_at", sa.DateTime(timezone=True), nullable=False), sa.UniqueConstraint("profile", "version", name="uq_models_generation_profile_version"), schema="models", ) op.create_index( "ux_models_generation_profiles_active", "generation_profiles", ["active"], unique=True, schema="models", postgresql_where=sa.text("active = true"), ) def downgrade() -> None: op.drop_index( "ux_models_generation_profiles_active", table_name="generation_profiles", schema="models", ) op.drop_table("generation_profiles", schema="models") op.execute(sa.text("DROP SCHEMA IF EXISTS models"))