#Syncing data between environments

1 messages · Page 1 of 1 (latest)

muted nimbus
#

Hi! I am working on a feature for my PayloadCMS-deployment. It is deployed to two environments, one staging-version and a live prod-version, each with its own postgres-database but with same config and so on.

I have built a custom <SyncButton /> component that I plan to add to collections I want to be able to sync between environments, and it works for items without relationships.

The logic goes like this:

User presses the button, the current env fetches the collection from the other env and uses it's local API to create or update the items in the collection.

I have a colleciton of Pages, and several elements in these pages reference another collection of Colors. The issue I'm facing now is that the IDs of the colors differ between the environments, and if I try to run payload.create or update with a depth greater than 0, it crashes, because it wants to insert the relationship by its ID and not the object itself.

Is there a way I can make payload.create set the created item's ID to match the incoming one, or somehow make the relationship fields use another form of matching other than ID?

Or is there an easier way to do this entirely? 😅

lament basinBOT
muted nimbus
#

I am still running on v2, with the postgres-adapter btw :) v2.29.0

ashen sonnet
#

Did this ever get resolved? I have similar issue where I need to know the id before I create a new entry so I can use that id elsewhere. Easy to do in mongo

muted nimbus
#

Haven't found a fix for it yet, no