Home / Blog posts

How We Migrated to Strapi v5: A No-Nonsense Guide

Strapi v5 migration cover
Preparation
  1. Backup Everything: We started with comprehensive backups of our project and database. No room for error here.
  2. Study the Docs: We dove into the Strapi v5 documentation to get a handle on new features and potential breaking changes.
Migration Steps
  1. Initialize Strapi v5: We set up a fresh Strapi v5 project:
  2. npx create-strapi-app my-project --quickstart
  3. Database Setup: Configured the database in config/database.js to match our current setup.
  4. Data Migration: Exported data from the old project and imported it into the new Strapi v5 instance using scripts.
  5. Rebuild Content Types: Manually recreated content types and reinstalled necessary plugins, checking for v5 compatibility.
  6. Code Refactor: Updated our custom code for compatibility with Strapi v5’s API and addressed any deprecated features.
Testing
  1. Local Tests: Ran the project locally to catch issues early.
  2. Staging Deployment: Deployed to a staging environment identical to production to identify environment-specific bugs.
Go Live
  1. Prep Production: Ensured the production environment was ready for Strapi v5.
  2. Deploy: Deployed to production and closely monitored the project.
  3. Verify: Checked data integrity and overall functionality post-deployment.
Lessons Learned
  1. Simpler Migration: The migration to v5 was smoother compared to the jump from v3 to v4, thanks to better automation by the Strapi team.
  2. Mono-repo Issues: Running Strapi v5 in a mono-repo setup can be problematic.
  3. Plugin Compatibility: Many third-party plugins are not yet compatible with v5.
  4. Import Handling: Adjust imports due to changes in Strapi v5’s export methods and address TypeScript issues.
  5. Automated Database Migration: This worked well, but note that table names are now shortened (e.g., “components” to “cmps”).
  6. User Permissions Bug: In @strapi/plugin-users-permissions 5.0.0-beta.7, we encountered bugs with field visibility and editing as a super admin.
  7. Backend Customization: Migrating backend code, especially lifecycle hooks and EntityService API usage, was necessary. We found that lifecycle hooks are triggered differently, and the afterUpdate lifecycle didn’t trigger as expected in beta.
  8. Frontend Adjustments: Our frontend needed tweaks to handle the new flattened API responses, requiring a document ID in requests.
  9. Upgrade Tool Limitations: The Strapi upgrade tool didn’t work for us, necessitating a manual migration.
Conclusion
  • Migrating to Strapi v5 was worth the effort for the performance and feature enhancements. By thoroughly preparing and testing, we minimized downtime and ensured a smooth transition. If you're planning a similar upgrade, keep these lessons in mind for a streamlined migration process.
  • Got a question? Shoot us an email to sales@notum-tech.ch
Got a project?
Jiri Mouka photo

Jiri Mouka | Founder

+41 076 629 91 78

sales@notum-tech.ch