-
-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy path20240523004032_redefine_authorization_tables.ex
45 lines (34 loc) · 1.33 KB
/
20240523004032_redefine_authorization_tables.ex
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
41
42
43
44
45
defmodule Realtime.Tenants.Migrations.RedefineAuthorizationTables do
@moduledoc false
use Ecto.Migration
def change do
drop table(:broadcasts, mode: :cascade)
drop table(:presences, mode: :cascade)
drop table(:channels, mode: :cascade)
create table(:messages) do
add :topic, :text, null: false
add :extension, :text, null: false
timestamps()
end
create index(:messages, [:topic])
execute("ALTER TABLE realtime.messages ENABLE row level security")
execute("GRANT SELECT ON realtime.messages TO postgres, anon, authenticated, service_role")
execute("GRANT UPDATE ON realtime.messages TO postgres, anon, authenticated, service_role")
execute("""
GRANT INSERT ON realtime.messages TO postgres, anon, authenticated, service_role
""")
execute("""
GRANT USAGE ON SEQUENCE realtime.messages_id_seq TO postgres, anon, authenticated, service_role
""")
execute("ALTER table realtime.messages OWNER to supabase_realtime_admin")
execute("""
DROP function realtime.channel_name
""")
execute("""
create or replace function realtime.topic() returns text as $$
select nullif(current_setting('realtime.topic', true), '')::text;
$$ language sql stable;
""")
execute("ALTER function realtime.topic() owner to supabase_realtime_admin")
end
end