···11+-- publication_contributors: who has been invited / accepted as a contributor to a publication
22+create table "public"."publication_contributors" (
33+ "publication_uri" text not null,
44+ "contributor_did" text not null,
55+ "confirmed" boolean not null default false,
66+ "created_at" timestamp with time zone not null default now()
77+);
88+99+alter table "public"."publication_contributors" enable row level security;
1010+1111+CREATE UNIQUE INDEX publication_contributors_pkey ON public.publication_contributors USING btree (publication_uri, contributor_did);
1212+1313+alter table "public"."publication_contributors" add constraint "publication_contributors_pkey" PRIMARY KEY using index "publication_contributors_pkey";
1414+1515+CREATE INDEX publication_contributors_contributor_did_idx ON public.publication_contributors USING btree (contributor_did);
1616+1717+alter table "public"."publication_contributors" add constraint "publication_contributors_publication_uri_fkey" FOREIGN KEY (publication_uri) REFERENCES publications(uri) ON DELETE CASCADE not valid;
1818+alter table "public"."publication_contributors" validate constraint "publication_contributors_publication_uri_fkey";
1919+2020+alter table "public"."publication_contributors" add constraint "publication_contributors_contributor_did_fkey" FOREIGN KEY (contributor_did) REFERENCES identities(atp_did) ON UPDATE CASCADE ON DELETE CASCADE not valid;
2121+alter table "public"."publication_contributors" validate constraint "publication_contributors_contributor_did_fkey";
2222+2323+grant delete on table "public"."publication_contributors" to "anon";
2424+grant insert on table "public"."publication_contributors" to "anon";
2525+grant references on table "public"."publication_contributors" to "anon";
2626+grant select on table "public"."publication_contributors" to "anon";
2727+grant trigger on table "public"."publication_contributors" to "anon";
2828+grant truncate on table "public"."publication_contributors" to "anon";
2929+grant update on table "public"."publication_contributors" to "anon";
3030+3131+grant delete on table "public"."publication_contributors" to "authenticated";
3232+grant insert on table "public"."publication_contributors" to "authenticated";
3333+grant references on table "public"."publication_contributors" to "authenticated";
3434+grant select on table "public"."publication_contributors" to "authenticated";
3535+grant trigger on table "public"."publication_contributors" to "authenticated";
3636+grant truncate on table "public"."publication_contributors" to "authenticated";
3737+grant update on table "public"."publication_contributors" to "authenticated";
3838+3939+grant delete on table "public"."publication_contributors" to "service_role";
4040+grant insert on table "public"."publication_contributors" to "service_role";
4141+grant references on table "public"."publication_contributors" to "service_role";
4242+grant select on table "public"."publication_contributors" to "service_role";
4343+grant trigger on table "public"."publication_contributors" to "service_role";
4444+grant truncate on table "public"."publication_contributors" to "service_role";
4545+grant update on table "public"."publication_contributors" to "service_role";
4646+4747+-- leaflet_contributors: who is a contributor on a specific draft.
4848+-- Each draft belongs to one publication, so we reference the draft (permission_token id) directly.
4949+create table "public"."leaflet_contributors" (
5050+ "leaflet" uuid not null,
5151+ "contributor_did" text not null,
5252+ "created_at" timestamp with time zone not null default now()
5353+);
5454+5555+alter table "public"."leaflet_contributors" enable row level security;
5656+5757+CREATE UNIQUE INDEX leaflet_contributors_pkey ON public.leaflet_contributors USING btree (leaflet, contributor_did);
5858+5959+alter table "public"."leaflet_contributors" add constraint "leaflet_contributors_pkey" PRIMARY KEY using index "leaflet_contributors_pkey";
6060+6161+CREATE INDEX leaflet_contributors_contributor_did_idx ON public.leaflet_contributors USING btree (contributor_did);
6262+6363+alter table "public"."leaflet_contributors" add constraint "leaflet_contributors_leaflet_fkey" FOREIGN KEY (leaflet) REFERENCES permission_tokens(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
6464+alter table "public"."leaflet_contributors" validate constraint "leaflet_contributors_leaflet_fkey";
6565+6666+alter table "public"."leaflet_contributors" add constraint "leaflet_contributors_contributor_did_fkey" FOREIGN KEY (contributor_did) REFERENCES identities(atp_did) ON UPDATE CASCADE ON DELETE CASCADE not valid;
6767+alter table "public"."leaflet_contributors" validate constraint "leaflet_contributors_contributor_did_fkey";
6868+6969+grant delete on table "public"."leaflet_contributors" to "anon";
7070+grant insert on table "public"."leaflet_contributors" to "anon";
7171+grant references on table "public"."leaflet_contributors" to "anon";
7272+grant select on table "public"."leaflet_contributors" to "anon";
7373+grant trigger on table "public"."leaflet_contributors" to "anon";
7474+grant truncate on table "public"."leaflet_contributors" to "anon";
7575+grant update on table "public"."leaflet_contributors" to "anon";
7676+7777+grant delete on table "public"."leaflet_contributors" to "authenticated";
7878+grant insert on table "public"."leaflet_contributors" to "authenticated";
7979+grant references on table "public"."leaflet_contributors" to "authenticated";
8080+grant select on table "public"."leaflet_contributors" to "authenticated";
8181+grant trigger on table "public"."leaflet_contributors" to "authenticated";
8282+grant truncate on table "public"."leaflet_contributors" to "authenticated";
8383+grant update on table "public"."leaflet_contributors" to "authenticated";
8484+8585+grant delete on table "public"."leaflet_contributors" to "service_role";
8686+grant insert on table "public"."leaflet_contributors" to "service_role";
8787+grant references on table "public"."leaflet_contributors" to "service_role";
8888+grant select on table "public"."leaflet_contributors" to "service_role";
8989+grant trigger on table "public"."leaflet_contributors" to "service_role";
9090+grant truncate on table "public"."leaflet_contributors" to "service_role";
9191+grant update on table "public"."leaflet_contributors" to "service_role";