Like what we’re doing? Star us on GitHub!

Does payloadcms provide any migration tools?

zhounewz
7 months ago
1 2

just like contentful-migration.

Planning to migrate from contentful to payloadcms

  • jmikrut
    Payload Team
    7 months ago

    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!

    4 replies
  • zhounewz
    7 months ago

    just like below?

    const pageReq = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/posts?limit=100`)
    
  • denolfe
    Payload Team
    7 months ago

    @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

  • zhounewz
    7 months ago

    @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

  • denolfe
    Payload Team
    7 months ago

    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.

  • DanRibbens
    Payload Team
    3 months ago

    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.

Open the post
Continue the discussion in GitHub
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More