Database changes when upgrading to Strapi 5

Strapi 5 drops MySQL 5 and non-better-sqlite3 SQLite setups and shortens long database identifiers, so the database must change before or during the upgrade. This page explains what to move, how to test the migration on a copy, and what drives the work.

On this page

What the Strapi 5 upgrade does to your database

Strapi 5 requires MySQL 8.0 or later, requires better-sqlite3 for SQLite projects, and shortens database identifiers longer than 55 characters through a data migration script. If your Strapi v4 project runs on MySQL 5, or on SQLite with a driver other than better-sqlite3, the database has to change before or during the move to Strapi 5, not after it. Identifiers that exceed 55 characters are shortened with a hash suffix when the data migration runs on first start, so table and column names in your database will change. Confirm the exact list of supported versions and the migration behavior against the Strapi v4 to v5 migration docs before you schedule the work.

The database work belongs to the same upgrade path as the code work, not to a separate maintenance task. Strapi's docs say to back up the database first because downgrading is not supported, so a failed migration cannot be reversed by reinstalling v4 code against the changed schema. Your plan should therefore include a verified backup taken immediately before the upgrade, a restore test, and a named owner who decides whether to roll forward or restore. The supported list also includes PostgreSQL 14 or later, MariaDB 10.3 or later and SQLite 3, so a move to a different engine is a possible option, though it adds a data move on top of the upgrade. Ask your team which of these engines your organization already operates and supports.

Test the whole migration on a copy of production data before any cutover. Restore the backup to a separate environment with the same database engine and version you will run in production, point a Strapi 5 instance at it, and let the data migration script run to completion. Check that every content type loads, that long identifiers resolved as expected, and that media and relations still point to the right records. Record the duration of the run and the database size before and after, since these figures set the maintenance window for the production upgrade. Your own environment, not a general estimate, should determine how long that window needs to be.

Database changes in Strapi 5 and what each one requires

This table lists each database change Strapi 5 brings, what it affects in your project, and the work you need to finish before the upgrade. Read each row against your current database engine and your custom queries. The main takeaway is that the MySQL and SQLite changes may need infrastructure work, while the identifier change can break hand-written SQL that references long names.

ChangeImpactAction needed
MySQL 5 unsupportedStrapi 5 requires MySQL 8.0 as the minimum, so a MySQL 5 database cannot be used after the upgrade.Confirm your server version, plan a MySQL 8.0 or later upgrade, and rehearse it on a copy of production data.
SQLite must use better-sqlite3Projects must use the better-sqlite3 package with client set to sqlite, so older SQLite driver setups stop working.Replace the driver dependency, update the client setting in the database configuration, and test local and CI startup.
Identifiers limited to 55 charactersTable and column names longer than 55 characters are shortened with a hash suffix by a data migration script, so raw SQL, reports and custom code that use the old names will fail.Search custom queries, views, BI tools and integrations for long names, then update them to the shortened names after a test run.
Supported engines: PostgreSQL 14+, MariaDB 10.3+, SQLite 3These are the engines Strapi 5 supports, and PostgreSQL 14 is the oldest PostgreSQL version in the supported list.Check the engine and version you run today, and upgrade the engine first if it falls outside this list.
No MongoDB or other NoSQL supportProjects on MongoDB or another NoSQL database have no supported path in Strapi 5, so the data must move to a supported relational engine.Plan a data move to a supported database before the upgrade, using a tested export and import process.
Data migration scripts run on first startStrapi 5 changes the schema when it first starts, so the database is altered without a manual step and cannot be reversed by a downgrade.Take a verified backup, run the migration on a restored copy first, and confirm the pre-upgrade backup can be restored.

Decide the database path before the upgrade starts

The diagram starts at the database engine your project runs today and follows one branch per engine. MySQL 5 must move to MySQL 8.0 or later first, SQLite projects switch to the better-sqlite3 driver with client set to sqlite, and MySQL 8.0, MariaDB 10.3 or later, and PostgreSQL projects confirm their versions are supported. Every branch then meets the same two checks: an inventory of identifiers longer than 55 characters, and a backup and restore test on a copy before the go or no-go decision for the upgrade sequence.

Each database engine branch ends in the same identifier and copy-test checks before the upgrade.

What to prepare before touching the database

These six items are the groundwork that makes a Strapi 5 database change reversible and testable. Each one answers a question the team must settle before the migration script runs: how to get back, what will break, which runtime is supported, and who decides.

Verified database backup

Take a full backup of the database before any upgrade step, and confirm it restores. Strapi's documentation says to back up the database first because downgrading is not supported, so this backup is the only way back once the Strapi 5 data migration has run. Record the backup time, the storage location and the checksum, and restore it to a scratch server to prove it is usable.

Strapi migration FAQ

Inventory of long identifiers

List every table and column name longer than 55 characters. Strapi 5 limits database identifiers to 55 characters and shortens longer ones with a hash suffix in a data migration script. Include names referenced in custom queries, raw SQL in plugins, reports, BI tools and stored views, because a renamed identifier will break any code that still uses the old name.

Node.js version check

Confirm the Node.js version on every build and runtime host against Strapi 5's requirement. Strapi 5 runs only on Active or Maintenance LTS Node.js versions, so an end-of-life runtime must be upgraded before the project will start. Check CI runners, container base images and the production server, since a version mismatch between them is a common cause of failed starts after a database change.

Strapi installation requirements

Test environment from a production copy

Build a staging environment from a recent copy of production data and run the full migration there first. The copy should match production's database engine and major version, character set and collation, and approximate data volume, so that the migration time and any identifier shortening can be observed. Keep the copy inside the same network controls as production, because it contains real personal data.

Database users, extensions and settings

Document every database user, role, extension, schema, connection string option and SSL setting that the Strapi configuration depends on. Check that the upgraded database version still provides each extension, and that the Strapi database user can create and alter the objects the migration needs. For SQLite projects, confirm the project uses the better-sqlite3 package with the client set to sqlite, since other SQLite drivers are not supported.

Named rollback owner and restore target

Name one person who has authority to call a rollback, and write down the restore time target before the change window opens. The owner should hold the backup location, the restore procedure and the decision criteria, such as migration errors or failed smoke tests. Agree the target with the business owner, because a restore from backup discards any content written after the backup was taken.

How the database move differs by current setup

Strapi 5 does not support MySQL 5, so the server must move to MySQL 8.0 or later before the new major version can start. This is the largest database change in the group because it involves the server itself, not only the application. Treat the server upgrade as its own project with its own backup and rollback point, and rehearse the identifier change on a copy of the database before anything touches production.

  • Upgrade the server first: Move to MySQL 8.0 or later and confirm the application connects with the upgraded server before you change Strapi.
  • Check the Strapi config: Confirm the connection settings point at the upgraded server, including host, port, and credentials.
  • Test identifier shortening on a copy: Run the Strapi 5 data migration against a restored copy and review which long identifiers were renamed.
  • Review application queries: Look for custom SQL or raw queries that reference shortened table or column names.
  • Record the server version: Keep the exact version in your upgrade notes so auditors can match it to the test run.

Before go-live, check that the Strapi configuration and the upgraded server agree, and that the copy test completed without errors.

Why PostgreSQL 17 or 18 is the safer target for new work

If you are choosing a database for a new Strapi 5 project, or moving a database that you will run for several years, target PostgreSQL 17 or 18 rather than the oldest version Strapi 5 accepts. PostgreSQL 18 is supported until November 14, 2030, PostgreSQL 17 until November 8, 2029, PostgreSQL 16 until November 9, 2028, PostgreSQL 15 until November 11, 2027, and PostgreSQL 14 until November 12, 2026. Versions 13 and earlier are no longer supported. Strapi 5 itself accepts PostgreSQL 14 or later, so a version that is supported by Strapi but near the end of its PostgreSQL window will need another upgrade within months. Confirm the current support dates on the PostgreSQL versioning page before you fix a target version, because a database that reaches end of life during your Strapi project's lifetime creates a second migration you did not plan for.

PostgreSQL is released under the PostgreSQL License, a permissive open source license similar to the BSD and MIT licenses, so licensing does not add a cost or a distribution condition to the database itself. Minor releases never change the internal storage format, which means routine patching is an executable replacement and restart. Major upgrades need a separate plan. The documented options are a dump and restore with pg_dumpall, pg_upgrade, or logical replication. Logical replication works across major versions and can limit downtime to several seconds, but it requires you to plan replication slots, sequence handling and the cutover procedure. Test whether your Strapi tables and sequences replicate as expected on a copy before you commit to that path.

Plan high availability and connection handling as separate decisions. PostgreSQL supports hot standby servers and both synchronous and asynchronous replication, but it does not include software that detects a primary failure and promotes a standby, so automatic failover requires an external tool that you select, configure and test. Connection pooling with PgBouncer is also a separate choice that affects how Strapi's connections behave under load and during failover. Neither decision is required by Strapi 5. Ask your database team to document the chosen tools, their owners and the recovery test they will run before the upgrade window opens.

The database upgrade sequence with checks and rollback points

This sequence moves a Strapi project's database to a Strapi 5 supported engine in a rehearsed order, so each step has a pass check and a known rollback point. The output is a production migration with a verified backup, recorded results and a documented way back if a check fails.

  1. Take and verify a full database backup

    Before anything else changes, the team takes a full backup of the production database and confirms it can be restored. The Strapi migration documentation says to back up the database first because downgrading is not supported, so this backup is the only rollback point. The step passes when a restore of the backup into a separate instance completes and the restored row counts match the source. Keep the backup, its checksum and the restore log with the change record.

  2. Inventory identifiers and custom SQL

    The engineer lists every table and column name that could exceed 55 characters, since Strapi 5 shortens longer database identifiers with a hash suffix through a data migration script. The same review covers raw SQL queries, custom migrations, database views and reporting tools that read Strapi tables directly, because renamed identifiers will break them. The step passes when the list is complete, each item has an owner, and each custom query is marked for update or confirmed unaffected. Confirm the exact naming rules against the Strapi breaking change page before you start.

  3. Build a copy of production in staging

    The team restores the verified backup into an isolated staging environment that matches production's engine version, configuration, file storage settings and environment variables. Staging must not connect to production services such as email, webhooks or third-party APIs during test runs. The step passes when the staging copy starts on the current Strapi 4 code, the admin panel loads and a sample of entries matches production. This copy is where every later rehearsal runs.

  4. Upgrade the database engine or driver on the copy

    On the copy only, the team upgrades the database to a version Strapi 5 supports. MySQL 5 is no longer supported, so MySQL 8.0 is the minimum, and SQLite projects must switch to the better-sqlite3 package with the client set to sqlite. For PostgreSQL, the team checks the supported versions and end-of-support dates in the PostgreSQL versioning policy and plans the major upgrade with pg_dumpall, pg_upgrade or logical replication. The step passes when the engine reports the target version, the application connects, and a read query returns the expected data.

  5. Run the upgrade tool and data migration on the copy

    The engineer runs the Strapi 5 upgrade tool and its codemods on the copy's code, then starts Strapi 5 so the data migration scripts run on first start, including identifier shortening. The team records the console output and any script that fails or warns. The step passes when Strapi 5 starts without migration errors and the migration log shows every script completed. If a script fails, the rollback point is the pre-upgrade backup restored into the copy, and the team fixes the cause before rerunning.

  6. Check counts, relations, drafts and media

    The team compares row counts for each content type and component against the pre-upgrade backup, then samples relations, published and draft versions, localized entries and media references. Media links are checked against the upload provider, since a broken reference will not show up in row counts. The automated test suite runs against the copy and results are recorded. The step passes when counts match, sampled relations and drafts render correctly in the admin panel and API, and tests pass or each failure has a documented decision. Any unexplained mismatch stops the sequence.

  7. Repeat on a fresh copy and schedule production

    The team repeats the full run from a new copy of the backup and records how long each step takes, so the production window is based on measured results. Once two clean runs match, the team agrees a change window with the business owners and freezes schema and content model changes for the period. The step passes when the timed runs are documented, the window is approved in writing and the rollback plan names who decides to restore the backup. Ask your partner or internal lead to confirm the timing for your data volume, since no general figure applies.

  8. Run production migration and record results

    With the verified backup in place and the freeze active, the team runs the database engine upgrade and the Strapi 5 migration on production using the same steps as the rehearsal. They repeat the count, relation, draft and media checks, run smoke tests on the admin panel and key API endpoints, and keep the backup available until sign-off. The step passes when the checks match the rehearsal results and the change record captures the backup location, migration log, check outcomes and sign-off. If a check fails, the team restores the pre-upgrade backup, since downgrade is not supported.

What makes the database work longer or shorter

This table lists the factors that lengthen or shorten database work before a Strapi 5 upgrade, with the effect each one has and what to confirm in your environment. Read each row against your own database and reporting setup, since the same driver can add a day of work for one team and almost none for another. The main takeaway is that the engine version, long identifiers and any direct SQL access usually decide the scope more than raw data size.

DriverEffect on the workWhat to confirm
Size of the database and media metadataLarger data increases the time to copy, back up and run the migration script on a test copyTotal database size, row counts for the largest tables, and whether media metadata sits in the same database
Tables and columns with names over 55 charactersStrapi 5 shortens long identifiers with a hash suffix in a data migration script, so every reference to those names must be checkedA list of long table, column and index names, and which of them appear in custom code or reports
Custom SQL, raw queries and reporting toolsQueries that read table names directly can break after identifiers are shortened or schema changes runEvery database user, report, dashboard and export job that connects to the Strapi database, and the table names each one reads
Plugins that add their own tablesPlugin tables follow their own schema and may need plugin updates before the upgrade can completeInstalled plugins, their Strapi 5 compatibility status, and the tables each one creates
Current engine and versionMySQL 5 must move to MySQL 8.0 or later, SQLite projects must switch to better-sqlite3, and supported versions need less changeExact engine and version in use, the driver in package.json for SQLite projects, and the target version in your hosting plan
Whether an engine upgrade must run in the same windowCombining a database engine upgrade with the Strapi upgrade doubles the variables if something failsWhether the engine upgrade can be done and tested separately before the Strapi upgrade starts
Number of environments sharing the databaseShared development, staging or reporting databases must be migrated together or separated, which adds coordinationWhich environments and teams use the same database, and who signs off each one
Ability to restore a copy within the planned windowWithout a tested restore, a failed migration may leave no clean state to return to, since downgrading is not supportedBackup method, restore test history, and whether a restored copy can be migrated end to end within the planned window

Questions teams ask before the database work starts

How much does the database work cost, and what drives the fee?

The fee follows from the written scope, and DeployOpen does not publish a price list. The main drivers are whether the database engine changes (for example MySQL 5 to MySQL 8.0, or SQLite to a different engine), how many environments need the migration rehearsed, how much custom SQL and how many plugin tables the project carries, and how many identifiers exceed the 55-character limit. Ask for a quote that lists each database, environment and test cycle as a separate line, and confirm whether the work is fixed-scope with agreed deliverables before testing starts. One-time work is the inventory, the engine change and the copy tests. Recurring costs, such as hosting and backups, sit outside this work and should be quoted separately.

How long does the database migration take?

The window depends on the size of the data, the number of identifiers that need shortening, and how many test cycles the copy needs before sign-off. No fixed duration applies to every project. The Strapi data migration script runs on the first start of Strapi 5, so its runtime grows with the database. Plan at least one full rehearsal on a copy of production, measure the run time, then repeat after each fix. Ask your partner or your own team to report the rehearsal timings and the list of identifiers that will be shortened before setting a production window.

What does the database work need from our team?

It needs four things. First, access to the database server, including a recent backup and a way to create a copy for testing. Second, access to the code repository so the team can see the custom queries and plugin configuration. Third, a named owner who signs off each test run against the expected content and workflows. Fourth, a backup window agreed with the business, because the production database must be backed up before the upgrade starts and must stay unchanged until the rehearsal results are accepted.

Can our own team do the database changes without a partner?

Yes, if the team has database administration skills for the engine you run, working knowledge of Strapi's data model, and time for several test cycles on copies. Start with the Strapi breaking change pages for MySQL 5, better-sqlite3 and database identifiers, then run the upgrade on a copy and check the results before touching production. A partner is most useful when the team lacks one of those skills, when the schema has heavy custom SQL, or when the release date leaves no room for repeated rehearsals.

Can we roll back the database after the Strapi 5 upgrade?

No. Strapi's migration documentation says downgrading is not supported, so a rollback means restoring the database from the backup taken before the upgrade and returning the code to the Strapi 4 version. That is why the tested copy matters: a successful rehearsal on a copy of production shows that the backup restores cleanly and that the migration completes. Confirm that backups are taken immediately before the window, that restores have been tested, and that the team knows who decides to roll back.

Should we move to PostgreSQL while we upgrade to Strapi 5?

Treat it as a separate decision with its own timing. Strapi 5 supports PostgreSQL 14 or later, MySQL 8.0 or later, MariaDB 10.3 or later and SQLite 3, so PostgreSQL is not required for the upgrade. PostgreSQL 14 reaches end of support in November 2026, so a new deployment should target a version with later support dates such as 17 or 18. Doing the engine change and the Strapi upgrade together adds risk, because a failure could come from either change. Many teams upgrade Strapi first on the engine they already run, then plan the PostgreSQL move as its own migration.

Which database engine does a Strapi 5 project need to support for our compliance review?

Strapi 5 supports the engines listed in its installation requirements, and it does not support MongoDB or other NoSQL databases. Your compliance and security teams should review the engine version, its support end date, its access controls, its backup and restore method and its encryption settings before approving the change. Confirm with the database vendor the security patch policy for the version you choose. DeployOpen prepares the evidence for those reviews but does not issue audit reports or certifications.

How DeployOpen scopes and delivers the database upgrade

DeployOpen plans the database side of a Strapi 5 upgrade as a written, fixed-scope piece of work. The scope covers the database engine, the version target, the identifier and SQLite changes, and a rehearsal of the migration on a copy of production data before any change reaches live systems.

How we scope

  • Inventory the current database engine, version, hosting model and every Strapi project that connects to it.
  • Check identifier lengths and the SQLite driver against Strapi 5 requirements before estimating the build.
  • Agree in writing which database versions, backups, copies and test runs are included in the fixed scope.
  • Record which items are out of scope, such as code changes, plugin ports or front-end updates, so costs stay visible.

How we build

  • Stand up the target database version in a non-production environment that matches your infrastructure.
  • Run the Strapi data migration against a restored copy of production data and log every failure or warning.
  • Test the migrated copy with editors' core workflows, API calls and scheduled jobs before sign-off.
  • Document the rollback point and the pre-upgrade backup so the cutover can be reversed if needed.

How we hand over

  • Deliver a runbook with the exact database steps, the migration log and the verification checklist used.
  • Hand over backup and restore procedures tested on the copy, with the restore commands your team will run.
  • Walk your database and platform engineers through the cutover sequence and the decision points.
  • List the database settings, credentials and version pins your team must own after the upgrade.

How we support

  • Support the production cutover window in the agreed scope and record what was changed.
  • Offer ongoing support, upgrades and continuous testing as a retainer after the engagement closes.
  • Confirm with your team which database maintenance tasks, such as minor version updates, stay in-house or move to a retainer.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.