4

I am using Strapi as a headless cms for my website. First I have started one version only on the production environment and there was no other environment like development or staging. So when I wanted to change the models (collections and single types or etc.) I had to switch the server to run in development mode to be able to do changes. So while doing these kinds of changes, the production environment also ran out of service. After a few days, the app crashed while trying to update the database and it never started again.
So now I highly need to separate the development environment from production. But I have some questions about how to do this, and can't find solutions:

  1. If I develop the app locally or in a separate development environment, how should I transfer the new models to the server?
  2. Does production environment data survive from migration process?
  3. Should I create a backup from production environment data every time I do the deployment (migration) process?
ConductedClever
  • 4,175
  • 2
  • 35
  • 69

3 Answers3

3

So when you're talking about migration in the development lifecycle of a project there are two things to take in to account:

  • Schema migrations
  • Content migrations

Schema migrations are handled by strapi automatically. You can just update the schema files locally and move them to production (like Shekhar suggested).

The other thing is content migrations. Strapi suggested a long overdue migrate CLI. I couldn't wait for this any longer so I've built this feature myself through a plugin called config-sync. This plugin can be used with Strapi v4 to export/import data through the CLI or GUI and migrate them across environments.

Hope this helps you construct a reliable development workflow in Strapi.

2

After a long time to read the docs and follow previously asked questions, I have found that this question was already asked before here: Running Strapi in production and version control sync issues and had no accepting answer and also discussed on https://github.com/strapi/strapi/issues/1986 and finally every one waiting for strapi migrate feature which is not even planned for future. There was another way which was a little hopeful to dump and restore configuration on dev and prod environments in https://strapi.io/documentation/developer-docs/latest/developer-resources/cli/CLI.html#strapi-configuration-dump although I haven't tested it. I continued reading about headless CMSs and found that solutions like Keystonejs and Payloadjs which let the developer define models in the code is more stable, maintainable and extendable so I have switched into Keystonejs right now.

ConductedClever
  • 4,175
  • 2
  • 35
  • 69
0

The way we have been doing the migration from staging to production is by seeing the differences in files in the Strapi projects between commits (e.g. models, etc.) and just moving and replacing the modified files to the production server.

We didn't migrate the data.

It's not seamless, but it works for us.

Shekhar Sahu
  • 504
  • 1
  • 6
  • 19