8000 fix: handle new Wrappers in create server sql (#35075) · CodersSampling/supabase@b7e9b82 · GitHub
[go: up one dir, main page]

Skip to content

Commit b7e9b82

Browse files
soedirgojoshenlim
andauthored
fix: handle new Wrappers in create server sql (supabase#35075)
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
1 parent cbc3534 commit b7e9b82

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

apps/studio/data/fdw/fdw-create-mutation.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,48 @@ export function getCreateFDWSql({
113113
const createServerSql = /* SQL */ `
114114
do $$
115115
declare
116+
-- Old wrappers has an implicit dependency on pgsodium. For new wrappers
117+
-- we use Vault directly.
118+
is_using_old_wrappers bool;
116119
${encryptedOptions.map((option) => `v_${option.name} text;`).join('\n')}
117120
begin
121+
is_using_old_wrappers := (select extversion from pg_extension where extname = 'wrappers') in (
122+
'0.1.0',
123+
'0.1.1',
124+
'0.1.4',
125+
'0.1.5',
126+
'0.1.6',
127+
'0.1.7',
128+
'0.1.8',
129+
'0.1.9',
130+
'0.1.10',
131+
'0.1.11',
132+
'0.1.12',
133+
'0.1.14',
134+
'0.1.15',
135+
'0.1.16',
136+
'0.1.17',
137+
'0.1.18',
138+
'0.1.19',
139+
'0.2.0',
140+
'0.3.0',
141+
'0.3.1',
142+
'0.4.0',
143+
'0.4.1',
144+
'0.4.2',
145+
'0.4.3',
146+
'0.4.4',
147+
'0.4.5'
148+
);
118149
${encryptedOptions
119150
.map(
120-
(option) =>
121-
/* SQL */ `select id into v_${option.name} from pgsodium.valid_key where name = '${formState.wrapper_name}_${option.name}' limit 1;`
151+
(option) => /* SQL */ `
152+
if is_using_old_wrappers then
153+
select id into v_${option.name} from pgsodium.valid_key where name = '${formState.wrapper_name}_${option.name}' limit 1;
154+
else
155+
select id into v_${option.name} from vault.secrets where name = '${formState.wrapper_name}_${option.name}' limit 1;
156+
end if;
157+
`
122158
)
123159
.join('\n')}
124160

0 commit comments

Comments
 (0)
0