"""Make account_id nullable for access_key credentials Revision ID: 002 Revises: 001 Create Date: 2026-01-02 00:00:00.000000 """ from alembic import op import sqlalchemy as sa # revision identifiers revision = '002' down_revision = '001' branch_labels = None depends_on = None def upgrade(): """Make account_id column nullable for access_key type credentials""" # Make account_id nullable with op.batch_alter_table('aws_credentials', schema=None) as batch_op: batch_op.alter_column('account_id', existing_type=sa.String(12), nullable=True) def downgrade(): """Revert account_id column to not nullable""" # First, update any NULL account_id values to a placeholder op.execute("UPDATE aws_credentials SET account_id = '000000000000' WHERE account_id IS NULL") # Make account_id not nullable again with op.batch_alter_table('aws_credentials', schema=None) as batch_op: batch_op.alter_column('account_id', existing_type=sa.String(12), nullable=False)