CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- noqa: RF05

CREATE TABLE collections (
    id UUID PRIMARY KEY,
    site UUID NOT NULL REFERENCES sites (id) ON DELETE CASCADE,
    slug VARCHAR NOT NULL,
    name VARCHAR NOT NULL,
    parent UUID REFERENCES collections (id) ON DELETE CASCADE
);

ALTER TABLE pages
ADD COLUMN collections UUID [] NOT NULL DEFAULT array[]::UUID[], -- noqa
ADD COLUMN published BOOLEAN NOT NULL DEFAULT FALSE;
