create table "public"."publication_pages" (
    "id" bigint generated by default as identity not null,
    "created_at" timestamp with time zone not null default now(),
    "leaflet_src" uuid not null,
    "document" text,
    "path" text,
    "publication" text not null,
    "title" text not null default '',
    "metadata" jsonb not null default '{}'::jsonb
);


alter table "public"."publication_pages" enable row level security;

CREATE UNIQUE INDEX publication_pages_pkey ON public.publication_pages USING btree (id, publication);

alter table "public"."publication_pages" add constraint "publication_pages_pkey" PRIMARY KEY using index "publication_pages_pkey";

alter table "public"."publication_pages" add constraint "publication_pages_document_fkey" FOREIGN KEY (document) REFERENCES documents(uri) not valid;

alter table "public"."publication_pages" validate constraint "publication_pages_document_fkey";

alter table "public"."publication_pages" add constraint "publication_pages_leaflet_src_fkey" FOREIGN KEY (leaflet_src) REFERENCES permission_tokens(id) not valid;

alter table "public"."publication_pages" validate constraint "publication_pages_leaflet_src_fkey";

alter table "public"."publication_pages" add constraint "publication_pages_publication_fkey" FOREIGN KEY (publication) REFERENCES publications(uri) ON UPDATE CASCADE ON DELETE CASCADE not valid;

alter table "public"."publication_pages" validate constraint "publication_pages_publication_fkey";

grant delete on table "public"."publication_pages" to "anon";

grant insert on table "public"."publication_pages" to "anon";

grant references on table "public"."publication_pages" to "anon";

grant select on table "public"."publication_pages" to "anon";

grant trigger on table "public"."publication_pages" to "anon";

grant truncate on table "public"."publication_pages" to "anon";

grant update on table "public"."publication_pages" to "anon";

grant delete on table "public"."publication_pages" to "authenticated";

grant insert on table "public"."publication_pages" to "authenticated";

grant references on table "public"."publication_pages" to "authenticated";

grant select on table "public"."publication_pages" to "authenticated";

grant trigger on table "public"."publication_pages" to "authenticated";

grant truncate on table "public"."publication_pages" to "authenticated";

grant update on table "public"."publication_pages" to "authenticated";

grant delete on table "public"."publication_pages" to "service_role";

grant insert on table "public"."publication_pages" to "service_role";

grant references on table "public"."publication_pages" to "service_role";

grant select on table "public"."publication_pages" to "service_role";

grant trigger on table "public"."publication_pages" to "service_role";

grant truncate on table "public"."publication_pages" to "service_role";

grant update on table "public"."publication_pages" to "service_role";
