mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 17:43:03 +03:00
18 lines
476 B
MySQL
18 lines
476 B
MySQL
|
CREATE OR REPLACE FUNCTION public.get_user_id_by_user_email(user_email text)
|
||
|
RETURNS TABLE (user_id uuid)
|
||
|
SECURITY DEFINER
|
||
|
AS $$
|
||
|
BEGIN
|
||
|
RETURN QUERY SELECT au.id::uuid FROM auth.users au WHERE au.email = user_email;
|
||
|
END;
|
||
|
$$ LANGUAGE plpgsql;
|
||
|
|
||
|
-- Update migrations table
|
||
|
INSERT INTO migrations (name)
|
||
|
SELECT '20230717173000_add_get_user_id_by_user_email'
|
||
|
WHERE NOT EXISTS (
|
||
|
SELECT 1 FROM migrations WHERE name = '20230717173000_add_get_user_id_by_user_email'
|
||
|
);
|
||
|
|
||
|
COMMIT;
|