"""add dataset columns

Revision ID: 7c330aebf8e7
Revises: 18b0dde1883b
Create Date: 2025-10-17 13:49:41.775680

"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "7c330aebf8e7"
down_revision = "18b0dde1883b"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "dataset_versions",
        sa.Column("column_names", sa.JSON(), nullable=True),
    )
    op.execute(
        """
        UPDATE dataset_versions
        SET column_names = '[]'
        WHERE column_names is null
        """,
    )
    op.alter_column("dataset_versions", "column_names", nullable=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("dataset_versions", "column_names")
    # ### end Alembic commands ###
