-
-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: evtrigs ownership #1526
Closed
Closed
fix: evtrigs ownership #1526
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
migrations/db/init-scripts/00000000000000-initial-schema.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
migrations/db/migrations/00000000000000-initial-schema.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
-- migrate:up | ||
|
||
-- Set up realtime | ||
do $$ | ||
begin | ||
if not exists ( | ||
select 1 from pg_catalog.pg_publication | ||
where pubname = 'supabase_realtime' | ||
) | ||
then | ||
set role postgres; | ||
create publication supabase_realtime; | ||
reset role; | ||
end if; | ||
end | ||
$$; | ||
|
||
-- Supabase super admin | ||
alter user supabase_admin with superuser createdb createrole replication bypassrls; | ||
|
||
-- Supabase replication user | ||
do $$ | ||
begin | ||
if not exists ( | ||
select 1 from pg_roles | ||
where rolname = 'supabase_replication_admin' | ||
) | ||
then | ||
create user supabase_replication_admin with | ||
login | ||
replication; | ||
end if; | ||
end | ||
$$; | ||
|
||
-- Supabase read-only user | ||
do $$ | ||
begin | ||
if not exists ( | ||
select 1 from pg_roles | ||
where rolname = 'supabase_read_only_user' | ||
) | ||
then | ||
create role supabase_read_only_user with | ||
login | ||
bypassrls; | ||
end if; | ||
end | ||
$$; | ||
grant pg_read_all_data to supabase_read_only_user; | ||
|
||
-- Extension namespacing | ||
create schema if not exists extensions; | ||
create extension if not exists "uuid-ossp" with schema extensions; | ||
create extension if not exists pgcrypto with schema extensions; | ||
-- newer versions don't have pgjwt available | ||
do $$ | ||
begin | ||
if exists ( | ||
select 1 from pg_available_extensions where name = 'pgjwt' | ||
) then | ||
create extension if not exists pgjwt with schema extensions; | ||
end if; | ||
end $$; | ||
|
||
-- Set up auth roles for the developer | ||
do $$ | ||
begin | ||
if not exists ( | ||
select 1 from pg_roles | ||
where rolname = 'anon' | ||
) | ||
then | ||
create role anon nologin noinherit; | ||
end if; | ||
end | ||
$$; | ||
|
||
-- "logged in" user: web_user, app_user, etc | ||
do $$ | ||
begin | ||
if not exists ( | ||
select 1 from pg_roles | ||
where rolname = 'authenticated' | ||
) | ||
then | ||
create role authenticated nologin noinherit; | ||
end if; | ||
end | ||
$$; | ||
|
||
-- allow developers to create JWT's that bypass their policies | ||
do $$ | ||
begin | ||
if not exists ( | ||
select 1 from pg_roles | ||
where rolname = 'service_role' | ||
) | ||
then | ||
create role service_role nologin noinherit bypassrls; | ||
end if; | ||
end | ||
$$; | ||
|
||
do $$ | ||
begin | ||
if not exists ( | ||
select 1 from pg_roles | ||
where rolname = 'authenticator' | ||
) | ||
then | ||
create role authenticator login noinherit; | ||
end if; | ||
end | ||
$$; | ||
|
||
|
||
grant anon to authenticator; | ||
grant authenticated to authenticator; | ||
grant service_role to authenticator; | ||
grant supabase_admin to authenticator; | ||
|
||
-- These are required so that the users receive grants whenever "postgres" creates tables/function | ||
grant usage on schema public to postgres, anon, authenticated, service_role; | ||
alter default privileges for role postgres in schema public grant all on tables to postgres, anon, authenticated, service_role; | ||
alter default privileges for role postgres in schema public grant all on functions to postgres, anon, authenticated, service_role; | ||
alter default privileges for role postgres in schema public grant all on sequences to postgres, anon, authenticated, service_role; | ||
|
||
-- Allow Extensions to be used in the API | ||
grant usage on schema extensions to postgres, anon, authenticated, service_role; | ||
|
||
-- Set up namespacing | ||
alter user supabase_admin SET search_path TO public, extensions; -- don't include the "auth" schema | ||
|
||
-- These are required so that the users receive grants whenever "supabase_admin" creates tables/function | ||
alter default privileges for user supabase_admin in schema public grant all | ||
on sequences to postgres, anon, authenticated, service_role; | ||
alter default privileges for user supabase_admin in schema public grant all | ||
on tables to postgres, anon, authenticated, service_role; | ||
alter default privileges for user supabase_admin in schema public grant all | ||
on functions to postgres, anon, authenticated, service_role; | ||
|
||
-- Set short statement/query timeouts for API roles | ||
alter role anon set statement_timeout = '3s'; | ||
alter role authenticated set statement_timeout = '8s'; | ||
|
||
-- migrate:down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually moved, but git/github doesn't recognize it as such because there are some modifications.