Does payloadcms provide any migration tools?

default discord avatar
blueMountain007last year
1 2

just like contentful-migration.

Planning to migrate from contentful to payloadcms

  • Selected Answer
    discord user avatar
    jmikrut
    last year

    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
  • default discord avatar
    blueMountain007last year

    just like below?

    const pageReq = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/posts?limit=100`)
    
  • discord user avatar
    denolfe
    last year

    @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

  • default discord avatar
    blueMountain007last year

    @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

  • discord user avatar
    denolfe
    last year

    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.

  • discord user avatar
    DanRibbens
    last year

    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 on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.