I am building a migration in Postgres where I need to add one new user for every organization.
Assuming that I have tree tables:
insert into users
from users where ...
If I'm understanding correctly, here's one option using an
inner join, and then establishing a
row_number per table to
insert into user_org select u.id, o.id from (select id, row_number() over (order by id) rn from usr) u join (select id, row_number() over (order by id) rn from org) o on u.rn = o.rn