@@ -78,6 +78,14 @@ CREATE SCHEMA realtime;
78
78
79
79
CREATE SCHEMA storage ;
80
80
81
+
82
+ --
83
+ -- Name: vault; Type: SCHEMA; Schema: -; Owner: -
84
+ --
85
+
86
+ CREATE SCHEMA vault ;
87
+
88
+
81
89
--
82
90
-- Name: pg_graphql; Type: EXTENSION; Schema: -; Owner: -
83
91
--
@@ -133,43 +141,19 @@ CREATE EXTENSION IF NOT EXISTS pgjwt WITH SCHEMA extensions;
133
141
134
142
COMMENT ON EXTENSION pgjwt IS ' JSON Web Token API for Postgresql' ;
135
143
144
+
136
145
--
146
+ -- Name: supabase_vault; Type: EXTENSION; Schema: -; Owner: -
137
147
--
138
- --
139
-
140
- DO $$
141
- DECLARE
142
- vault_exists boolean ;
143
- BEGIN
144
- vault_exists = (
145
- select count (* ) = 1
146
- from pg_available_extensions
147
- where name = ' supabase_vault'
148
- );
149
-
150
- IF vault_exists
151
- THEN
152
-
153
- --
154
- -- Name: vault; Type: SCHEMA; Schema: -; Owner: -
155
- --
156
148
157
- CREATE SCHEMA vault ;
158
- --
159
- -- Name: supabase_vault; Type: EXTENSION; Schema: -; Owner: -
160
- --
149
+ CREATE EXTENSION IF NOT EXISTS supabase_vault WITH SCHEMA vault;
161
150
162
- CREATE EXTENSION IF NOT EXISTS supabase_vault WITH SCHEMA vault;
163
151
152
+ --
153
+ -- Name: EXTENSION supabase_vault; Type: COMMENT; Schema: -; Owner: -
154
+ --
164
155
165
- --
166
- -- Name: EXTENSION supabase_vault; Type: COMMENT; Schema: -; Owner: -
167
- --
168
-
169
- COMMENT ON EXTENSION supabase_vault IS ' Supabase Vault Extension' ;
170
-
171
- END IF;
172
- END $$;
156
+ COMMENT ON EXTENSION supabase_vault IS ' Supabase Vault Extension' ;
173
157
174
158
175
159
--
@@ -593,38 +577,23 @@ $$;
593
577
-- Name: secrets_encrypt_secret_secret(); Type: FUNCTION; Schema: vault; Owner: -
594
578
--
595
579
596
- DO $$
597
- DECLARE
598
- vault_exists boolean ;
599
- BEGIN
600
- vault_exists = (
601
- select count (* ) = 1
602
- from pg_available_extensions
603
- where name = ' supabase_vault'
604
- );
605
-
606
- IF vault_exists
607
- THEN
608
-
609
- CREATE FUNCTION vault .secrets_encrypt_secret_secret() RETURNS trigger
610
- LANGUAGE plpgsql
611
- AS $$
612
- BEGIN
613
- new .secret = CASE WHEN new .secret IS NULL THEN NULL ELSE
614
- CASE WHEN new .key_id IS NULL THEN NULL ELSE pg_catalog .encode (
615
- pgsodium .crypto_aead_det_encrypt (
616
- pg_catalog .convert_to (new .secret , ' utf8' ),
617
- pg_catalog .convert_to ((new .id ::text || new .description ::text || new .created_at ::text || new .updated_at ::text )::text , ' utf8' ),
618
- new .key_id ::uuid,
619
- new .nonce
620
- ),
621
- ' base64' ) END END;
622
- RETURN new;
623
- END;
624
- $$;
580
+ CREATE FUNCTION vault .secrets_encrypt_secret_secret() RETURNS trigger
581
+ LANGUAGE plpgsql
582
+ AS $$
583
+ BEGIN
584
+ new .secret = CASE WHEN new .secret IS NULL THEN NULL ELSE
585
+ CASE WHEN new .key_id IS NULL THEN NULL ELSE pg_catalog .encode (
586
+ pgsodium .crypto_aead_det_encrypt (
587
+ pg_catalog .convert_to (new .secret , ' utf8' ),
588
+ pg_catalog .convert_to ((new .id ::text || new .description ::text || new .created_at ::text || new .updated_at ::text )::text , ' utf8' ),
589
+ new .key_id ::uuid,
590
+ new .nonce
591
+ ),
592
+ ' base64' ) END END;
593
+ RETURN new;
594
+ END;
595
+ $$;
625
596
626
- END IF;
627
- END $$;
628
597
629
598
SET default_tablespace = ' ' ;
630
599
@@ -816,40 +785,25 @@ CREATE TABLE storage.objects (
816
785
-- Name: decrypted_secrets; Type: VIEW; Schema: vault; Owner: -
817
786
--
818
787
819
- DO $$
820
- DECLARE
821
- vault_exists boolean ;
822
- BEGIN
823
- vault_exists = (
824
- select count (* ) = 1
825
- from pg_available_extensions
826
- where name = ' supabase_vault'
827
- );
828
-
829
- IF vault_exists
830
- THEN
831
-
832
- CREATE VIEW vault .decrypted_secrets AS
833
- SELECT secrets .id ,
834
- secrets .name ,
835
- secrets .description ,
836
- secrets .secret ,
788
+ CREATE VIEW vault .decrypted_secrets AS
789
+ SELECT secrets .id ,
790
+ secrets .name ,
791
+ secrets .description ,
792
+ secrets .secret ,
793
+ CASE
794
+ WHEN (secrets .secret IS NULL ) THEN NULL ::text
795
+ ELSE
837
796
CASE
838
- WHEN (secrets .secret IS NULL ) THEN NULL ::text
839
- ELSE
840
- CASE
841
- WHEN (secrets .key_id IS NULL ) THEN NULL ::text
842
- ELSE convert_from(pgsodium .crypto_aead_det_decrypt (decode(secrets .secret , ' base64' ::text ), convert_to(((((secrets .id )::text || secrets .description ) || (secrets .created_at )::text ) || (secrets .updated_at )::text ), ' utf8' ::name), secrets .key_id , secrets .nonce ), ' utf8' ::name)
843
- END
844
- END AS decrypted_secret,
845
- secrets .key_id ,
846
- secrets .nonce ,
847
- secrets .created_at ,
848
- secrets .updated_at
849
- FROM vault .secrets ;
797
+ WHEN (secrets .key_id IS NULL ) THEN NULL ::text
798
+ ELSE convert_from(pgsodium .crypto_aead_det_decrypt (decode(secrets .secret , ' base64' ::text ), convert_to(((((secrets .id )::text || secrets .description ) || (secrets .created_at )::text ) || (secrets .updated_at )::text ), ' utf8' ::name), secrets .key_id , secrets .nonce ), ' utf8' ::name)
799
+ END
800
+ END AS decrypted_secret,
801
+ secrets .key_id ,
802
+ secrets .nonce ,
803
+ secrets .created_at ,
804
+ secrets .updated_at
805
+ FROM vault .secrets ;
850
806
851
- END IF;
852
- END $$;
853
807
854
808
--
855
809
-- Name: refresh_tokens id; Type: DEFAULT; Schema: auth; Owner: -
0 commit comments