Migrating blocks field #6514
Unanswered
siccifolium
asked this question in
Q&A
Replies: 1 comment
-
Depending on your database. If it's mongodb you could write an aggregation pipeline to update the database directly. https://www.mongodb.com/docs/manual/core/aggregation-pipeline/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the best approach when I have a collection with a
blocks
field with a couple of different blocks and at one point in time I need to change the shape/structure of one of the blocks. How do I update the already existing documents which make use of this block type?So far my approach is to implement a migration file which loops over all documents in a collection and then reads the
blocks
field and manually iterates through all the blocks and migrates the data. Then the updated document is updated via the payload local api.Is there a better approach to this problem? Am I overseeing a more obvious solution?
My suggested solutions has some downsides, for example for every migration a new version of the document is created.
Beta Was this translation helpful? Give feedback.
All reactions