-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase_schema.sql
More file actions
40 lines (31 loc) · 1.19 KB
/
supabase_schema.sql
File metadata and controls
40 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
create table if not exists public.messages (
id bigint generated by default as identity primary key,
room text not null,
username text not null,
message_type text not null check (message_type in ('text', 'file')),
text text,
file_url text,
file_path text,
file_name text,
file_type text,
file_size integer,
created_at timestamptz not null default now(),
expires_at timestamptz not null default (now() + interval '5 hours')
);
alter table public.messages
add column if not exists file_path text;
alter table public.messages
add column if not exists expires_at timestamptz;
update public.messages
set expires_at = created_at + interval '5 hours'
where expires_at is null;
alter table public.messages
alter column expires_at set default (now() + interval '5 hours');
alter table public.messages
alter column expires_at set not null;
create index if not exists messages_room_created_at_idx
on public.messages (room, created_at desc);
create index if not exists messages_expires_at_idx
on public.messages (expires_at);
alter table public.messages enable row level security;
drop policy if exists "Allow public read messages" on public.messages;