Pipeline/backend/migrations/versions/c4a1d2e3f4a5_make_main_sess...

34 lines
907 B
Python

"""Make main_session_key nullable on gateways.
The column was NOT NULL but the ORM model didn't include it, causing
INSERT failures when creating gateways via the API. The field gets
populated by ensure_main_agent() after the row exists, so it needs
to be nullable during the initial INSERT.
Revision ID: c4a1d2e3f4a5
Revises: f7d8e9a0b1c2
Create Date: 2026-05-21 04:25:00.000000
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "c4a1d2e3f4a5"
down_revision = "f7d8e9a0b1c2"
branch_labels = None
depends_on = None
def upgrade() -> None:
"""Allow main_session_key to be NULL on initial insert."""
op.alter_column("gateways", "main_session_key", nullable=True)
def downgrade() -> None:
"""Revert main_session_key to NOT NULL."""
op.alter_column("gateways", "main_session_key", nullable=False)