-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
there is no parameter $1 #6094
Comments
If there is an existing database with its own schema / data, you would need to write a Payload config to match its shape perfectly before starting up. It’s not expected that Payload will instantly work with any existing database - at least not right now. |
@jmikrut could you explain this a bit more, please? Assuming I have a DB schema with 30+ tables and complex relationships (and it's possibly evolving), how (and why) would I have to add this to the Payload config? |
Sure thing! So, Payload requires you to define your schema in the Payload config, so that we can surface it in our APIs as well as allow the admin UI to be generated appropriately. It is specific to Payload and is not agnostic regarding existing database shape, by design. Although you have an existing schema defined in your database, Payload does not introspect your existing DB to dynamically build its own schema from your existing DB at all. So, if you connect to an existing database, unless your database matched what Payload's schema was defined as, there would be all sorts of things that would blow up. Right now at least, Payload is not designed to be able to import any Postgres schema into its own configuration. We could allow for this in the future, but as of now, this is not how things work. So you're gonna have problems unless you migrate your data to the shape that Payload would expect. It's possible that in the future we could certainly introspect your database shape and allow you to map your existing table structures over to what Payload needs, but that will be no small feat, because of the complex field types that Payload supports (blocks, nested relationships, arrays, Payload also supports versions and other complex db-level structures, so if you were to want to have Payload match your existing database shape, you would be missing out on a lot of the features that Payload provides and then would likely have to run DB migrations in order to add additional functionality. You can, however, import your existing data into Payload using the Payload Local API once you have your new Payload config defined as you want it. Does this make sense? Can I ask why you're interested in bringing 30+ pre-existing tables into Payload? What would your best-case scenario look like here? What would you like to have the result look like / function like after having Payload connect to your existing DB? |
Ah, this makes sense. Is it possible to specify a separate Postgres schema for Payload to use? So, I keep my core app DB in the
Sure. So, I have an existing app where I'd like to integrate Payload as a CMS. It would be used mainly to edit a couple of articles a month and handle some files. I also plan to customize Payload admin so the admin user would be able to use some fields to query data from the core app database. |
Yes - pass https://payloadcms.com/docs/database/postgres#options Everything else you mentioned should then work perfectly there! |
The error might actually be related to your connection string then, in that case. Have you double-checked that your connection string is valid? |
Yes, and I tried multiple databases. I tried a local postgres running in Docker, and with 2 Supabase projects. The only time I was able to get through this was when trying a completely new DB. |
Link to reproduction
No response
Describe the Bug
If Payload v3 is added to an existing app with data in the DB, it fails to initialize payload tables.
To Reproduce
/admin
Payload Version
3.0.0-beta.18
Adapters and Plugins
No response
The text was updated successfully, but these errors were encountered: