|
| 1 | +create table "public"."messages" ( |
| 2 | + "id" bigint generated by default as identity not null, |
| 3 | + "created_at" timestamp with time zone not null default now(), |
| 4 | + "room_id" bigint not null, |
| 5 | + "user_id" uuid not null default auth.uid(), |
| 6 | + "content" text not null |
| 7 | +); |
| 8 | + |
| 9 | + |
| 10 | +alter table "public"."messages" enable row level security; |
| 11 | + |
| 12 | +create table "public"."room_participants" ( |
| 13 | + "id" bigint generated by default as identity not null, |
| 14 | + "joined_at" timestamp with time zone not null default now(), |
| 15 | + "user_id" uuid not null, |
| 16 | + "room_id" bigint not null |
| 17 | +); |
| 18 | + |
| 19 | + |
| 20 | +alter table "public"."room_participants" enable row level security; |
| 21 | + |
| 22 | +create table "public"."rooms" ( |
| 23 | + "id" bigint generated by default as identity not null, |
| 24 | + "created_at" timestamp with time zone not null default now(), |
| 25 | + "name" character varying not null, |
| 26 | + "is_private" boolean not null default true |
| 27 | +); |
| 28 | + |
| 29 | + |
| 30 | +alter table "public"."rooms" enable row level security; |
| 31 | + |
| 32 | +CREATE UNIQUE INDEX messages_pkey ON public.messages USING btree (id); |
| 33 | + |
| 34 | +CREATE UNIQUE INDEX room_participants_pkey ON public.room_participants USING btree (id); |
| 35 | + |
| 36 | +CREATE UNIQUE INDEX rooms_pkey ON public.rooms USING btree (id); |
| 37 | + |
| 38 | +alter table "public"."messages" add constraint "messages_pkey" PRIMARY KEY using index "messages_pkey"; |
| 39 | + |
| 40 | +alter table "public"."room_participants" add constraint "room_participants_pkey" PRIMARY KEY using index "room_participants_pkey"; |
| 41 | + |
| 42 | +alter table "public"."rooms" add constraint "rooms_pkey" PRIMARY KEY using index "rooms_pkey"; |
| 43 | + |
| 44 | +alter table "public"."messages" add constraint "messages_room_id_fkey" FOREIGN KEY (room_id) REFERENCES rooms(id) ON DELETE CASCADE not valid; |
| 45 | + |
| 46 | +alter table "public"."messages" validate constraint "messages_room_id_fkey"; |
| 47 | + |
| 48 | +alter table "public"."messages" add constraint "messages_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; |
| 49 | + |
| 50 | +alter table "public"."messages" validate constraint "messages_user_id_fkey"; |
| 51 | + |
| 52 | +alter table "public"."room_participants" add constraint "room_participants_room_id_fkey" FOREIGN KEY (room_id) REFERENCES rooms(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; |
| 53 | + |
| 54 | +alter table "public"."room_participants" validate constraint "room_participants_room_id_fkey"; |
| 55 | + |
| 56 | +alter table "public"."room_participants" add constraint "room_participants_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; |
| 57 | + |
| 58 | +alter table "public"."room_participants" validate constraint "room_participants_user_id_fkey"; |
| 59 | + |
| 60 | +grant delete on table "public"."messages" to "anon"; |
| 61 | + |
| 62 | +grant insert on table "public"."messages" to "anon"; |
| 63 | + |
| 64 | +grant references on table "public"."messages" to "anon"; |
| 65 | + |
| 66 | +grant select on table "public"."messages" to "anon"; |
| 67 | + |
| 68 | +grant trigger on table "public"."messages" to "anon"; |
| 69 | + |
| 70 | +grant truncate on table "public"."messages" to "anon"; |
| 71 | + |
| 72 | +grant update on table "public"."messages" to "anon"; |
| 73 | + |
| 74 | +grant delete on table "public"."messages" to "authenticated"; |
| 75 | + |
| 76 | +grant insert on table "public"."messages" to "authenticated"; |
| 77 | + |
| 78 | +grant references on table "public"."messages" to "authenticated"; |
| 79 | + |
| 80 | +grant select on table "public"."messages" to "authenticated"; |
| 81 | + |
| 82 | +grant trigger on table "public"."messages" to "authenticated"; |
| 83 | + |
| 84 | +grant truncate on table "public"."messages" to "authenticated"; |
| 85 | + |
| 86 | +grant update on table "public"."messages" to "authenticated"; |
| 87 | + |
| 88 | +grant delete on table "public"."messages" to "service_role"; |
| 89 | + |
| 90 | +grant insert on table "public"."messages" to "service_role"; |
| 91 | + |
| 92 | +grant references on table "public"."messages" to "service_role"; |
| 93 | + |
| 94 | +grant select on table "public"."messages" to "service_role"; |
| 95 | + |
| 96 | +grant trigger on table "public"."messages" to "service_role"; |
| 97 | + |
| 98 | +grant truncate on table "public"."messages" to "service_role"; |
| 99 | + |
| 100 | +grant update on table "public"."messages" to "service_role"; |
| 101 | + |
| 102 | +grant delete on table "public"."room_participants" to "anon"; |
| 103 | + |
| 104 | +grant insert on table "public"."room_participants" to "anon"; |
| 105 | + |
| 106 | +grant references on table "public"."room_participants" to "anon"; |
| 107 | + |
| 108 | +grant select on table "public"."room_participants" to "anon"; |
| 109 | + |
| 110 | +grant trigger on table "public"."room_participants" to "anon"; |
| 111 | + |
| 112 | +grant truncate on table "public"."room_participants" to "anon"; |
| 113 | + |
| 114 | +grant update on table "public"."room_participants" to "anon"; |
| 115 | + |
| 116 | +grant delete on table "public"."room_participants" to "authenticated"; |
| 117 | + |
| 118 | +grant insert on table "public"."room_participants" to "authenticated"; |
| 119 | + |
| 120 | +grant references on table "public"."room_participants" to "authenticated"; |
| 121 | + |
| 122 | +grant select on table "public"."room_participants" to "authenticated"; |
| 123 | + |
| 124 | +grant trigger on table "public"."room_participants" to "authenticated"; |
| 125 | + |
| 126 | +grant truncate on table "public"."room_participants" to "authenticated"; |
| 127 | + |
| 128 | +grant update on table "public"."room_participants" to "authenticated"; |
| 129 | + |
| 130 | +grant delete on table "public"."room_participants" to "service_role"; |
| 131 | + |
| 132 | +grant insert on table "public"."room_participants" to "service_role"; |
| 133 | + |
| 134 | +grant references on table "public"."room_participants" to "service_role"; |
| 135 | + |
| 136 | +grant select on table "public"."room_participants" to "service_role"; |
| 137 | + |
| 138 | +grant trigger on table "public"."room_participants" to "service_role"; |
| 139 | + |
| 140 | +grant truncate on table "public"."room_participants" to "service_role"; |
| 141 | + |
| 142 | +grant update on table "public"."room_participants" to "service_role"; |
| 143 | + |
| 144 | +grant delete on table "public"."rooms" to "anon"; |
| 145 | + |
| 146 | +grant insert on table "public"."rooms" to "anon"; |
| 147 | + |
| 148 | +grant references on table "public"."rooms" to "anon"; |
| 149 | + |
| 150 | +grant select on table "public"."rooms" to "anon"; |
| 151 | + |
| 152 | +grant trigger on table "public"."rooms" to "anon"; |
| 153 | + |
| 154 | +grant truncate on table "public"."rooms" to "anon"; |
| 155 | + |
| 156 | +grant update on table "public"."rooms" to "anon"; |
| 157 | + |
| 158 | +grant delete on table "public"."rooms" to "authenticated"; |
| 159 | + |
| 160 | +grant insert on table "public"."rooms" to "authenticated"; |
| 161 | + |
| 162 | +grant references on table "public"."rooms" to "authenticated"; |
| 163 | + |
| 164 | +grant select on table "public"."rooms" to "authenticated"; |
| 165 | + |
| 166 | +grant trigger on table "public"."rooms" to "authenticated"; |
| 167 | + |
| 168 | +grant truncate on table "public"."rooms" to "authenticated"; |
| 169 | + |
| 170 | +grant update on table "public"."rooms" to "authenticated"; |
| 171 | + |
| 172 | +grant delete on table "public"."rooms" to "service_role"; |
| 173 | + |
| 174 | +grant insert on table "public"."rooms" to "service_role"; |
| 175 | + |
| 176 | +grant references on table "public"."rooms" to "service_role"; |
| 177 | + |
| 178 | +grant select on table "public"."rooms" to "service_role"; |
| 179 | + |
| 180 | +grant trigger on table "public"."rooms" to "service_role"; |
| 181 | + |
| 182 | +grant truncate on table "public"."rooms" to "service_role"; |
| 183 | + |
| 184 | +grant update on table "public"."rooms" to "service_role"; |
| 185 | + |
| 186 | + |
0 commit comments