Files
Convivo/supabase/migrations/20261010183614_preserve_sessions_on_unchanged_ticket.sql
T
f32289f583 fix: preserve week-long sessions and add profile mascot
Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
2026-10-10 20:40:42 +02:00

14 lines
1.1 KiB
SQL

do $migration$
declare
definition text;
old_block text := E' else\n update auth.users\n set encrypted_password = extensions.crypt(v_pw, extensions.gen_salt(''bf'')),\n updated_at = now()\n where id = v_uid;\n delete from auth.sessions where user_id = v_uid;\n end if;';
new_block text := E' else\n perform 1 from auth.users where id = v_uid for update;\n if exists (\n select 1 from auth.users\n where id = v_uid\n and encrypted_password is distinct from extensions.crypt(v_pw, encrypted_password)\n ) then\n update auth.users\n set encrypted_password = extensions.crypt(v_pw, extensions.gen_salt(''bf'')),\n updated_at = now()\n where id = v_uid;\n delete from auth.sessions where user_id = v_uid;\n end if;\n end if;';
begin
select pg_get_functiondef('public._ensure_auth_user(text,text,text)'::regprocedure) into definition;
if strpos(definition, old_block) = 0 then
raise exception 'Unexpected _ensure_auth_user password update block';
end if;
execute replace(definition, old_block, new_block);
end;
$migration$;