Closed piraka9011 closed 9 months ago
Hi @piraka9011,
What version of @payloadcms/db-postgres
are you on? I believe this was fixed in that package already.
I upgraded @payloadcms/db-postgres
from 0.2.2 to 0.3.1
My full dependency list:
"dependencies": {
"@payloadcms/bundler-webpack": "^1.0.5",
"@payloadcms/db-postgres": "^0.3.1",
"@payloadcms/plugin-cloud": "^2.0.0",
"@payloadcms/plugin-cloud-storage": "^1.1.1",
"@payloadcms/richtext-lexical": "^0.5.1",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "^2.7.0"
},
"devDependencies": {
"@types/express": "^4.17.9",
"copyfiles": "^2.4.1",
"lint-staged": "^15.2.0",
"nodemon": "^2.0.6",
"prettier": "^3.1.1",
"ts-node": "^9.1.1",
"typescript": "^4.8.4"
},
"resolutions": {
"jackspeak": "2.1.1"
}
I now get a bunch of webpack errors when running yarn dev
(set as cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon
The error is a few hundred lines so I just truncated to show the webpack build errors
yarn run v1.22.18
$ cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon
[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node src/server.ts -- -I`
[20:05:09] INFO (payload): Starting Payload...
[20:05:09] INFO (payload): Payload Admin URL: /admin
...
ERROR in ./node_modules/drizzle-kit/node_modules/minimatch/dist/mjs/unescape.d.ts.map 1:10
Module parse failed: Unexpected token (1:10)
...
ERROR in ./node_modules/hanji/readline.js 7:21-40
Module not found: Error: Can't resolve 'readline' in '/Users/allabana/tarteel_ws/payload-cms/node_modules/hanji'
Did you mean './readline'?
...
ERROR in node:zlib
Module build failed: UnhandledSchemeError: Reading from "node:zlib" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
...
webpack compiled with 124 errors and 152 warnings
I noticed db-postgres targets payload 2.0.0 https://github.com/payloadcms/payload/blob/main/packages/db-postgres/package.json#L39
Maybe that's the reason?
On my setup, after I add to CollectionConfig: versions: { drafts: true, },
All pages (created before this change) disappear from the pages list UI. Not sure if this is intended behaviour.
UPDATE: Another possibly related issue
Sorry—there is nothing to correspond with your request.
Looking into the DB, the page XY versions remain there in the "_pages_versions" table. I suppose version from there is listed on the admin console, despite its parent entry no longer being present at the "pages" table.
Note that versions was added after the collection was originally created.
This really is the crux of the issue. Changing a collection from unversioned to versioned or vice versa has some pretty large implications on storage data structure and querying of that data.
It sounds like we need to make this clearer in our documentation that making this change has these implications and the user should be expected to migrate some data to the new structure.
the user should be expected to migrate some data to the new structure.
If this is even possible, adding an example would be very helpful!
Otherwise, maybe you could recommend creating a new V2
of the existing collection and then migrating the data over from the old one.
I think we're going to handle this on our end with a migration that can be pulled in. Just created a POC branch that we'll work off of: https://github.com/payloadcms/payload/tree/poc/feat-versions-migration.
Stay tuned. Closing this one, though.
Note that versions was added after the collection was originally created.
This really is the crux of the issue. Changing a collection from unversioned to versioned or vice versa has some pretty large implications on storage data structure and querying of that data.
It sounds like we need to make this clearer in our documentation that making this change has these implications and the user should be expected to migrate some data to the new structure.
From the docs:
Versions are extremely performant and totally opt-in. They don't change the shape of your data at all. All versions are stored in a separate Collection and can be turned on and off easily at your discretion.
So how do I get out of this? Just copy the https://github.com/payloadcms/payload/blob/63380dc3d946485002261904c99af78854bb993a/packages/payload/src/database/migrations/exampleVersionsMigration.ts into my migrations directory?
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
Link to reproduction
No response
Describe the Bug
When trying to save a new collection where versions and drafts are enabled i.e.
then I cannot save/publish a new collection. I get a "Something went wrong" error in the UI (500) and the following logs:
I tried dropping all migrations and recreating them, but it still did not work.
To Reproduce
This is the collection we have defined. Note that
versions
was added after the collection was originally created. I tried this on both payload 2.0.0 and 2.7.0Payload Version
2.7.0
Adapters and Plugins
db-postgres, bundler-webpack, plugin-cloud-storage