I ran into an issue deploying the multi-tenant demo. The database seeding throws the error "error: insert or update on table "users_tenants_roles" violates foreign key constraint "users_tenants_roles_parent_id_users_tenants_id_fk"" on both Neon and Supabase.
I did a bit of digging and figured out that I could run the migrate command, which successfully pushed up to both Neon and Supabase. I disabled the payload seed and DB drop in the .env and everything loaded fine. I tried it again with the payload seed enabled, which at least seeded the super user and a couple of tenants.
While doing some digging, I did come across this and applied the workaround, so I do not know if that's needed as well for this workaround. If required, I can revert the changes and give it a shot.https://github.com/drizzle-team/drizzle-orm/issues/636
I did reference this as well, but I am on the latest version of the postgresql connector.https://github.com/payloadcms/payload/issues/3568
Is it something to do with the seed.ts in the example?
We have been doing some work today getting the seeding working properly with Postgres. The latest updates to the templates may resolve your issues.
I don't think is to do with the seed process - the same error is thrown when you manually add a tenant to a user in the UI and set their tenant role. It seems like it's adding the users_tenants_roles before the users_tenants
Something that could be useful is to be able to turn on the drizzle logging so we can see the SQL queries that are being send to the db
Can you open an issue for the first item, and a github discussion feature request for the second?
Yes I can
Hello, any news on this?
ps - I think the issue happens too when you are creating a relationship between user and tenant using pg as database.
Any updates will be on the above links