-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
180 additions
and
17 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
migrations/db/migrations/20221207154255_create_pgsodium_and_vault.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,40 @@ | ||
-- migrate:up | ||
|
||
DO $$ | ||
DECLARE | ||
pgsodium_exists boolean; | ||
vault_exists boolean; | ||
BEGIN | ||
pgsodium_exists = ( | ||
select count(*) = 1 | ||
from pg_available_extensions | ||
where name = 'pgsodium' | ||
and default_version in ('3.1.6', '3.1.7', '3.1.8', '3.1.9') | ||
); | ||
|
||
vault_exists = ( | ||
select count(*) = 1 | ||
from pg_available_extensions | ||
where name = 'supabase_vault' | ||
); | ||
|
||
IF pgsodium_exists | ||
THEN | ||
create extension if not exists pgsodium; | ||
|
||
grant pgsodium_keyiduser to postgres with admin option; | ||
grant pgsodium_keyholder to postgres with admin option; | ||
grant pgsodium_keymaker to postgres with admin option; | ||
|
||
grant execute on function pgsodium.crypto_aead_det_decrypt(bytea, bytea, uuid, bytea) to service_role; | ||
grant execute on function pgsodium.crypto_aead_det_encrypt(bytea, bytea, uuid, bytea) to service_role; | ||
grant execute on function pgsodium.crypto_aead_det_keygen to service_role; | ||
|
||
IF vault_exists | ||
THEN | ||
create extension if not exists supabase_vault; | ||
END IF; | ||
END IF; | ||
END $$; | ||
|
||
-- migrate:down |
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
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
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
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