"""add visualisations [24552f3be1f2].

Revision ID: 24552f3be1f2
Revises: 279d55228d28
Create Date: 2025-10-24 07:56:57.575675

"""

import sqlalchemy as sa
import sqlmodel
from alembic import op

# revision identifiers, used by Alembic.
revision = "24552f3be1f2"
down_revision = "279d55228d28"
branch_labels = None
depends_on = None


def upgrade() -> None:
    """Upgrade database schema and/or data, creating a new revision."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "curated_visualization",
        sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column("created", sa.DateTime(), nullable=False),
        sa.Column("updated", sa.DateTime(), nullable=False),
        sa.Column("project_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column(
            "artifact_visualization_id",
            sqlmodel.sql.sqltypes.GUID(),
            nullable=False,
        ),
        sa.Column(
            "display_name", sqlmodel.sql.sqltypes.AutoString(), nullable=True
        ),
        sa.Column("display_order", sa.Integer(), nullable=True),
        sa.Column(
            "layout_size", sqlmodel.sql.sqltypes.AutoString(), nullable=False
        ),
        sa.Column("resource_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
        sa.Column(
            "resource_type", sqlmodel.sql.sqltypes.AutoString(), nullable=False
        ),
        sa.ForeignKeyConstraint(
            ["artifact_visualization_id"],
            ["artifact_visualization.id"],
            name="fk_curated_visualization_artifact_visualization_id",
            ondelete="CASCADE",
        ),
        sa.ForeignKeyConstraint(
            ["project_id"],
            ["project.id"],
            name="fk_curated_visualization_project_id_project",
            ondelete="CASCADE",
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint(
            "artifact_visualization_id",
            "resource_id",
            "resource_type",
            name="unique_curated_visualization_resource_link",
        ),
    )

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade database schema and/or data back to the previous revision."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("curated_visualization")
    # ### end Alembic commands ###
