a tool for shared writing and social publishing
at main 184 lines 7.1 kB view raw
1create table "public"."entity_sets" ( 2 "id" uuid not null default gen_random_uuid(), 3 "created_at" timestamp with time zone not null default now() 4); 5 6 7alter table "public"."entity_sets" enable row level security; 8 9create table "public"."permission_token_rights" ( 10 "token" uuid not null, 11 "entity_set" uuid not null, 12 "read" boolean not null default false, 13 "write" boolean not null default false, 14 "created_at" timestamp with time zone not null default now(), 15 "create_token" boolean not null default false, 16 "change_entity_set" boolean not null default false 17); 18 19 20alter table "public"."permission_token_rights" enable row level security; 21 22create table "public"."permission_tokens" ( 23 "id" uuid not null default gen_random_uuid(), 24 "root_entity" uuid not null 25); 26 27 28alter table "public"."permission_tokens" enable row level security; 29 30alter table "public"."entities" add column "set" uuid not null; 31 32CREATE UNIQUE INDEX entity_sets_pkey ON public.entity_sets USING btree (id); 33 34CREATE UNIQUE INDEX permission_token_rights_pkey ON public.permission_token_rights USING btree (token, entity_set); 35 36CREATE UNIQUE INDEX permission_tokens_pkey ON public.permission_tokens USING btree (id); 37 38alter table "public"."entity_sets" add constraint "entity_sets_pkey" PRIMARY KEY using index "entity_sets_pkey"; 39 40alter table "public"."permission_token_rights" add constraint "permission_token_rights_pkey" PRIMARY KEY using index "permission_token_rights_pkey"; 41 42alter table "public"."permission_tokens" add constraint "permission_tokens_pkey" PRIMARY KEY using index "permission_tokens_pkey"; 43 44alter table "public"."entities" add constraint "entities_set_fkey" FOREIGN KEY (set) REFERENCES entity_sets(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; 45 46alter table "public"."entities" validate constraint "entities_set_fkey"; 47 48alter table "public"."permission_token_rights" add constraint "permission_token_rights_entity_set_fkey" FOREIGN KEY (entity_set) REFERENCES entity_sets(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; 49 50alter table "public"."permission_token_rights" validate constraint "permission_token_rights_entity_set_fkey"; 51 52alter table "public"."permission_token_rights" add constraint "permission_token_rights_token_fkey" FOREIGN KEY (token) REFERENCES permission_tokens(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; 53 54alter table "public"."permission_token_rights" validate constraint "permission_token_rights_token_fkey"; 55 56alter table "public"."permission_tokens" add constraint "permission_tokens_root_entity_fkey" FOREIGN KEY (root_entity) REFERENCES entities(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; 57 58alter table "public"."permission_tokens" validate constraint "permission_tokens_root_entity_fkey"; 59 60grant delete on table "public"."entity_sets" to "anon"; 61 62grant insert on table "public"."entity_sets" to "anon"; 63 64grant references on table "public"."entity_sets" to "anon"; 65 66grant select on table "public"."entity_sets" to "anon"; 67 68grant trigger on table "public"."entity_sets" to "anon"; 69 70grant truncate on table "public"."entity_sets" to "anon"; 71 72grant update on table "public"."entity_sets" to "anon"; 73 74grant delete on table "public"."entity_sets" to "authenticated"; 75 76grant insert on table "public"."entity_sets" to "authenticated"; 77 78grant references on table "public"."entity_sets" to "authenticated"; 79 80grant select on table "public"."entity_sets" to "authenticated"; 81 82grant trigger on table "public"."entity_sets" to "authenticated"; 83 84grant truncate on table "public"."entity_sets" to "authenticated"; 85 86grant update on table "public"."entity_sets" to "authenticated"; 87 88grant delete on table "public"."entity_sets" to "service_role"; 89 90grant insert on table "public"."entity_sets" to "service_role"; 91 92grant references on table "public"."entity_sets" to "service_role"; 93 94grant select on table "public"."entity_sets" to "service_role"; 95 96grant trigger on table "public"."entity_sets" to "service_role"; 97 98grant truncate on table "public"."entity_sets" to "service_role"; 99 100grant update on table "public"."entity_sets" to "service_role"; 101 102grant delete on table "public"."permission_token_rights" to "anon"; 103 104grant insert on table "public"."permission_token_rights" to "anon"; 105 106grant references on table "public"."permission_token_rights" to "anon"; 107 108grant select on table "public"."permission_token_rights" to "anon"; 109 110grant trigger on table "public"."permission_token_rights" to "anon"; 111 112grant truncate on table "public"."permission_token_rights" to "anon"; 113 114grant update on table "public"."permission_token_rights" to "anon"; 115 116grant delete on table "public"."permission_token_rights" to "authenticated"; 117 118grant insert on table "public"."permission_token_rights" to "authenticated"; 119 120grant references on table "public"."permission_token_rights" to "authenticated"; 121 122grant select on table "public"."permission_token_rights" to "authenticated"; 123 124grant trigger on table "public"."permission_token_rights" to "authenticated"; 125 126grant truncate on table "public"."permission_token_rights" to "authenticated"; 127 128grant update on table "public"."permission_token_rights" to "authenticated"; 129 130grant delete on table "public"."permission_token_rights" to "service_role"; 131 132grant insert on table "public"."permission_token_rights" to "service_role"; 133 134grant references on table "public"."permission_token_rights" to "service_role"; 135 136grant select on table "public"."permission_token_rights" to "service_role"; 137 138grant trigger on table "public"."permission_token_rights" to "service_role"; 139 140grant truncate on table "public"."permission_token_rights" to "service_role"; 141 142grant update on table "public"."permission_token_rights" to "service_role"; 143 144grant delete on table "public"."permission_tokens" to "anon"; 145 146grant insert on table "public"."permission_tokens" to "anon"; 147 148grant references on table "public"."permission_tokens" to "anon"; 149 150grant select on table "public"."permission_tokens" to "anon"; 151 152grant trigger on table "public"."permission_tokens" to "anon"; 153 154grant truncate on table "public"."permission_tokens" to "anon"; 155 156grant update on table "public"."permission_tokens" to "anon"; 157 158grant delete on table "public"."permission_tokens" to "authenticated"; 159 160grant insert on table "public"."permission_tokens" to "authenticated"; 161 162grant references on table "public"."permission_tokens" to "authenticated"; 163 164grant select on table "public"."permission_tokens" to "authenticated"; 165 166grant trigger on table "public"."permission_tokens" to "authenticated"; 167 168grant truncate on table "public"."permission_tokens" to "authenticated"; 169 170grant update on table "public"."permission_tokens" to "authenticated"; 171 172grant delete on table "public"."permission_tokens" to "service_role"; 173 174grant insert on table "public"."permission_tokens" to "service_role"; 175 176grant references on table "public"."permission_tokens" to "service_role"; 177 178grant select on table "public"."permission_tokens" to "service_role"; 179 180grant trigger on table "public"."permission_tokens" to "service_role"; 181 182grant truncate on table "public"."permission_tokens" to "service_role"; 183 184grant update on table "public"."permission_tokens" to "service_role";