mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
feat: add 20230717164900_add_get_user_email_by_user_id (#675)
This commit is contained in:
parent
f63136350b
commit
f8fce33191
17
scripts/20230717164900_add_get_user_email_by_user_id.sql
Normal file
17
scripts/20230717164900_add_get_user_email_by_user_id.sql
Normal file
@ -0,0 +1,17 @@
|
||||
CREATE OR REPLACE FUNCTION public.get_user_email_by_user_id(user_id uuid)
|
||||
RETURNS TABLE (email text)
|
||||
SECURITY definer
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT au.email::text FROM auth.users au WHERE au.id = user_id;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- Update migrations table
|
||||
INSERT INTO migrations (name)
|
||||
SELECT '20230717164900_add_get_user_email_by_user_id'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM migrations WHERE name = '20230717164900_add_get_user_email_by_user_id'
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -166,13 +166,22 @@ CREATE TABLE IF NOT EXISTS brain_subscription_invitations (
|
||||
FOREIGN KEY (brain_id) REFERENCES brains (brain_id)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.get_user_email_by_user_id(user_id uuid)
|
||||
RETURNS TABLE (email text)
|
||||
SECURITY definer
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT au.email::text FROM auth.users au WHERE au.id = user_id;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS migrations (
|
||||
name VARCHAR(255) PRIMARY KEY,
|
||||
executed_at TIMESTAMPTZ DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
INSERT INTO migrations (name)
|
||||
SELECT '202307111517031_change_vectors_id_type'
|
||||
SELECT '20230717164900_add_get_user_email_by_user_id'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM migrations WHERE name = '202307111517031_change_vectors_id_type'
|
||||
SELECT 1 FROM migrations WHERE name = '20230717164900_add_get_user_email_by_user_id'
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user