Mobile support to come.
..20260117042027_create_users.down.sql20260117042027_create_users.up.sql20260117043157_create_organizations.down.sql20260117043157_create_organizations.up.sql20260118222626_create_repositories.down.sql20260118222626_create_repositories.up.sql20260125182548_create_questions.down.sql20260125182548_create_questions.up.sql20260126215900_create_votes.down.sql20260126215900_create_votes.up.sql20260201050312_create_oauth.down.sql20260201050312_create_oauth.up.sql20260206190315_create_commits.down.sql20260206190315_create_commits.up.sql20260207120000_disable_auth_user_trigger.down.sql20260207120000_disable_auth_user_trigger.up.sql
-- Re-create the trigger function to auto-create user when auth.users row is created
CREATE OR REPLACE FUNCTION public.handle_new_auth_user()
RETURNS TRIGGER AS $$
BEGIN
INSERT INTO public.users (id, name, email, created_at)
VALUES (
NEW.id,
COALESCE(NEW.raw_user_meta_data->>'name', SPLIT_PART(NEW.email, '@', 1)),
NEW.email,
NOW()
)
ON CONFLICT (id) DO NOTHING;
RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
-- Re-create the trigger on auth.users table
CREATE TRIGGER on_auth_user_created
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE FUNCTION public.handle_new_auth_user();