This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
PostgresAdapter beforeSchemaInit does not handle sql views #8994
Labels
You can continue the conversation there. Go to discussion →
Describe the Bug
The docs state about
beforeSchemaInit
:The ability to perserve existing database structure is however limited to databases that have tables that are not to be managed by Payload.
If the DB has SQL views defiend, Drizzle will attempt to delete those views and there is no way in the
PostgresSchema
type to add views, it only supports Enums, Relations and Tables.Drizzle itself supports adding
pgView
, but that feature does not seem to be propagated.Link to the code that reproduces this issue
https://github.com/payloadcms/payload/blob/beta/packages/drizzle/src/postgres/types.ts
Reproduction Steps
One easy way to reproduce is to enable the very popular PostGIS extension in a Postgres database
and then try to enable Payload for that database. The extra
spatial_ref_sys
table required by PostGIS can be handled inbeforeSchemaInit
but the required views can not. Drizzle will try to delete them, which will fail.Which area(s) are affected? (Select all that apply)
db-postgres
Environment Info
Binaries:
Node: 20.11.0
npm: 10.8.2
Yarn: 1.22.19
pnpm: 9.12.2
Relevant Packages:
payload: 3.0.0-beta.123
next: 15.0.1
@payloadcms/db-mongodb: 3.0.0-beta.123
@payloadcms/db-postgres: 3.0.0-beta.123
@payloadcms/graphql: 3.0.0-beta.123
@payloadcms/next/utilities: 3.0.0-beta.123
@payloadcms/richtext-lexical: 3.0.0-beta.123
@payloadcms/richtext-slate: 3.0.0-beta.123
@payloadcms/translations: 3.0.0-beta.123
@payloadcms/ui/shared: 3.0.0-beta.123
react: 19.0.0-rc-65a56d0e-20241020
react-dom: 19.0.0-rc-65a56d0e-20241020
The text was updated successfully, but these errors were encountered: