Open mcornielje090404 opened 7 months ago
I'm glad you pointed this out! I ran into some odd behavior in my testing and couldn't recreate it so I moved on. This explains what I was seeing now, thanks for opening this issue!
@mcornielje090404 I can't decide if this needs to be an additional configurable property or if it is better to simply pass the db adapter schemaName
through to drizzle in the schemaFilter
property.
It seems reasonable to say that each Payload project can only use one schema and enforce that this way.
@DanRibbens I reckon since we can only have 1 schema at any given point currently just automatically pass it through, would reduce possibility of devs accidentally missing it. Can revise later if changes are made to schema handling in Payload. Edit: and drizzle*
Link to reproduction
No response
Describe the Bug
I am working on a project that requires the ability to use different schemas within the DB.
I have managed to setup targeting a custom schema successfully but have noticed when attempting to push to the schema via payload an error occurs if any of the tables in the new schema have the same name as a 'public' schema table.
For instance if I have a 'users_organisations' table on public and then point payload to a 'test' schema I cannot push my tables to the 'test' schema without receiving the following error.
After a little while of debugging and testing I realised that if I dropped my public schema so that it did not contain the 'users_organisations' table I could then push to the 'test' schema successfully.
In the drizzle documentation there is mention that you cannot have the same table across multiple schemas however, this can be bypassed using a schemaFilter.
I noticed in the codebase for payload/db-postgres there was no usage of the schemaFilter nor any way to add your own usage of the schemaFilter.
I believe implementing a way to add your own schemaFilter to the postgres db adapter would allow circumventing of this limitation and resolve it until drizzle develop a more permanent solution to the issue.
Note: This works fine the other way around from my testing. Having a 'test' schema table and then pushing a 'public' schema table with the same name goes through fine.
To Reproduce
Payload Version
3.0.0-alpha.49
Adapters and Plugins
@payloadcms/db-postgres