Home / Blog posts

Migrate Strapi v3 to v4

Ondrej Janosik Strapi migration v3 to v4
To upgrade or not to upgrade

If you're contemplating upgrading your STRAPI project from v3 to v4, you're in the right place. This guide will walk you through the benefits, the process, and potential pitfalls to ensure a smooth and successful migration.

Why Upgrade to STRAPI v4?

Pros:

  1. New Features and Larger Ecosystem: STRAPI v4 introduces a wealth of new features, enhancing functionality and user experience.
  2. Free RBAC (Role-Based Access Control): Improve your project's security and manage user permissions with ease.
  3. Future Updates and Security Improvements: Stay up-to-date with the latest improvements and security patches.
  4. Enhanced Developer Experience (DX): Enjoy a more streamlined and efficient development process.

Cons:

  1. No Support for MongoDB: STRAPI v4 no longer supports MongoDB, which may require switching to a different database.
  2. Significant Migration Effort: Migrating from v3 to v4 can be a considerable task, especially for large projects.
  3. Potential Impact on Project Development Speed: The migration process could temporarily slow down your project's development.
How to Upgrade

To assist with the migration, the official STRAPI website offers a detailed migration guide, along with additional resources in the official documentation.

Essential Steps:

  1. Code Migration (50%): Update both your frontend and backend code to be compatible with v4.
  2. Data Migration (35%): Transfer your data from v3 to v4, ensuring compatibility and integrity.
  3. Plugin Migration (0%): Optionally, follow the plugin migration guide if you use custom plugins.
  4. Update Consumer Applications (15%): Ensure that all applications consuming your STRAPI APIs are updated to work with the new version.
Preparation is Key:
  • Understand Differences Between v3 and v4: Familiarize yourself with the new features and changes in v4.
  • Cleanse the Database: Ensure your database models and schemas are clean and ready for migration.
  • Understand Migration Scripts: Study and understand the migration scripts to avoid surprises during the process.
  • Decide Between Updating or Rewriting: Assess your project's technical debt and overuse of STRAPI features to determine whether an update or a complete rewrite is necessary.
How Much Work Will It Be?

The amount of work required for migration depends on several factors:

  • Collection Types: The more collection types and components, the more work is needed.
  • Database: Migrating SQL databases is generally more straightforward than migrating from MongoDB.
  • Custom Code: Custom code impacts the migration effort. Some v3 plugins may not be compatible with v4.
  • Other Factors: Front-end data access abstraction, user management customizations, and admin interface customizations can also affect the migration effort.
Estimated Effort:
  • Small Projects: Minimal customizations can typically be migrated within a day or two.
  • Medium Projects: Projects like STRAPI.io took around 20 man-days, including frontend, backend, and data migration.
  • Large Projects: Extensive custom code may require a complete rewrite while still migrating the database, making it hard to estimate the effort precisely.
Potential Pitfalls to Avoid
  • Immersion Depths: Ensure your project does not exceed the maximum immersion depth of 3 in v4.
  • Familiarize Yourself with SQL Databases: If you're transitioning from MongoDB, get comfortable with SQL databases.
  • Plugin Limitations: Be aware that some plugins may not be available or compatible with v4.
  • Update and Fix Scripts on Staging DB Snapshot: Always test your scripts on a staging database before applying them to production.
  • Database Backup: Perform a thorough backup of your database and triple-check migrated data.
  • Seek Help When Needed: Don't hesitate to ask for assistance from the community or professional services.
Conclusion

Upgrading to STRAPI v4 can unlock a host of new features and improvements for your project. While the migration process can be challenging, careful preparation and understanding of the steps involved can lead to a successful transition. Embrace the change, and enjoy the enhanced capabilities of STRAPI v4.

For more detailed guidance, visit the official STRAPI migration guide.

Happy migrating! 🚀

Need more help?

Contact us
Ondřej Janošík
CEO @NOTUM
sales@notum-tech.ch

Got a project?
Jiri Mouka photo

Jiri Mouka | Founder

+41 076 629 91 78

sales@notum-tech.ch