just like contentful-migration.
Planning to migrate from contentful to payloadcms
Hey @zhounewz — thanks for the question!
Right now, because Payload has a very powerful Local Node API, you can write migration scripts in your code very easily. As long as you can export content from Contentful in JSON or similar, you can then loop over that content in a script, and for each doc, create a doc within Payload using the local API. It's pretty easy!
just like below?
const pageReq = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/posts?limit=100`)
@zhounewz Here is an example of using the local API to seed data. You would use this same method to read and then modify the data to your liking.
Another option is using a migration tool like mongoose-migrate or migrate-mongo
@denolfe Thank you for such a detailed answer. I just wrote a simple demo with rest api and it ran successfully. so I wonder if rest api is also an option?
By the way, the contentful used before and the payload used now are distributed in 2 different code repositories, in my opinion, rest api may be an easy solution. What do you think
Yes, REST API is always an option. The reason local API is usually a better option is there is less overhead, and it circumvents access control.
I made a sample repo that has migrations inside a Payload project using migrate-mongo
and it worked pretty well in my testing, see https://github.com/payloadcms/migrate-mongo-example.
I'll write a blog post about it and depending on reception, it could be added to the Payload docs.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.