"""Add user-scoped workbench layouts."""
from alembic import op

revision = "20260716_30"
down_revision = "20260716_20"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.execute("""
        CREATE TABLE IF NOT EXISTS public.workbench_layouts (
            user_id UUID PRIMARY KEY REFERENCES public.users(id) ON DELETE CASCADE,
            layout_version INTEGER NOT NULL DEFAULT 1 CHECK (layout_version > 0),
            widgets JSONB NOT NULL,
            updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
        );
    """)


def downgrade() -> None:
    pass
