Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing Strapi locally and deploy on production server

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?
like image 353
ConductedClever Avatar asked Oct 24 '25 17:10

ConductedClever


2 Answers

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.

like image 173
Boaz Poolman Avatar answered Oct 26 '25 12:10

Boaz Poolman


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.

like image 36
ConductedClever Avatar answered Oct 26 '25 11:10

ConductedClever