Migrate Users to SupabaseTE.01
FIGURE.01
Demo post with original placeholder copy. The idea: import users idempotently with a small SQL function.
create or replace function import_user(p_email text)
returns uuid language plpgsql as $$
declare id uuid;
begin
insert into profiles (email) values (p_email)
on conflict (email) do nothing
returning user_id into id;
return id;
end $$;
Validate emails first, run in a transaction, and log skipped rows.
Run it safely
Import in small batches so a bad row can’t half-write your tables. Return the existing id on conflict instead of erroring out.
select import_user('demo@example.com');
After the run, count rows on both sides and diff the email sets. Anything left over goes to a reject log you can reprocess later, and rotate the service key you used for the import when done.