Changing the Strapi database from SQLite or MySQL to PostgreSQL

A planned move from SQLite or MySQL to PostgreSQL for a Strapi project, using documented export and import paths, checked connection settings and tests of relations and media before cutover.

On this page

Moving a Strapi project from SQLite or MySQL to PostgreSQL: what the change involves

Moving a Strapi project from SQLite or MySQL to PostgreSQL is a planned export, import and verification job, not a change to a configuration file. Pointing the database connection at a new server only creates an empty schema, and the content, relations, media references and admin users still have to be moved and checked. Treat the switch as a project with a rehearsal, a cutover window and a sign-off step, and keep the current database untouched until the new one has passed those checks.

The effort depends on three things: how large and how relation-heavy the schema is, how media is stored (local uploads folder or an external upload provider), and how many environments must move, such as development, staging and production. A project with a few content types and local uploads is a small job. A project with dynamic zones, many relations, custom database queries or several environments that each hold different content needs more rehearsal runs. Strapi 5 supports PostgreSQL 14 or later, so confirm the PostgreSQL major version against the Strapi installation requirements before you choose a target. Your PostgreSQL version should also be one that is still supported; the supported versions list in the PostgreSQL policy is the place to check that.

Before scoping the work, ask your team or partner to confirm four things in writing: the Strapi version and Node.js version in use, the source database engine and version, the media storage location, and the list of environments that must end up on PostgreSQL. Those answers determine the export method, the number of test cycles and whether the work can be fixed-scope. Plan the verification checks, such as record counts per content type, spot checks of relations and media links, and admin login tests, before the first rehearsal so the team knows what a passing result looks like.

Which Strapi database features carry over to PostgreSQL and which need checking

This table compares SQLite, MySQL and MariaDB source setups with PostgreSQL on the points that most often change during a database move. Read each row as a checklist: the migration note says what to expect, and the verification column says what to test after the switch. Most differences surface in data types, relations and media references, so those rows deserve the most time.

FeatureSource databases (SQLite, MySQL, MariaDB)PostgreSQL target and what to verify
Supported database engineSQLite 3, MySQL 8.0 or later, and MariaDB 10.3 or later are supported by Strapi 5PostgreSQL 14 or later is supported. MongoDB and other NoSQL databases are not supported, so no document store is an option for this move
Data types and precisionMySQL and MariaDB use their own integer, decimal and text types, and SQLite uses loose type affinityColumn types are mapped during transfer. Check decimals, long text, booleans and date-time values against source rows, especially timezone handling
Relations and join tablesRelations are stored in join tables that Strapi manages, and the constraints depend on the engineConfirm row counts in each join table and walk several relations per content type, including components and dynamic zones
Schema and migration stateStrapi keeps its schema and migration history in the database, and the source may hold older migration recordsConfirm the target starts from a consistent schema and that no pending migrations or stale tables were carried over
Auto-increment IDsMySQL and MariaDB use auto-increment counters, and SQLite uses rowid behaviorCheck that PostgreSQL sequences are reset above the highest imported ID so that new entries do not collide with existing ones
Case sensitivityMySQL collations are often case-insensitive by default, while PostgreSQL comparisons are case-sensitiveTest filters, unique slugs and lookups that depend on case, since queries that matched before may return different results
JSON fieldsMySQL and MariaDB JSON handling and SQLite text-based JSON differ in validation and operatorsConfirm JSON content survives the move intact and that any custom queries against JSON columns return the same results
Database user and connection settingsSource setups often use a root or shared account with a local socket or simple host settingsCreate a dedicated PostgreSQL role with only the privileges Strapi needs, set SSL options and connection limits, and confirm the connection settings in the environment file
Media and file referencesUpload records in the database point to files stored on disk or in a providerConfirm media records still resolve to files after the switch, since the database move does not copy binary files by itself

Documented export, import and transfer paths for a Strapi database change

Moving a Strapi project from SQLite or MySQL to PostgreSQL can use Strapi's own transfer and export tooling or a native database dump. Each path moves a different set of data, so the choice depends on what your project stores outside the database. The cards below cover what each option carries, what it leaves behind, and what to verify before cutover.

Strapi transfer between instances

Strapi's transfer tooling copies content and related data from one running Strapi project to another over a live connection. The target can be a fresh Strapi project connected to PostgreSQL, which keeps the source database untouched during the move. Confirm whether your version transfers media files, users, roles and API tokens, and whether the target content types must match the source exactly before you run it. Check the command syntax and flags in the Strapi docs for your exact version, since transfer behavior has changed across releases.

Strapi export and import files

The export command writes an archive of content data, and the import command loads that archive into a target project. This path suits moves where the source and target cannot reach each other over a network, because the archive can be stored and checked before import. Confirm which parts are included by default, such as schema, entries, media and configuration, and which need an explicit flag. Test the import on a copy of the target first, and keep the archive with its checksum so you can prove what was loaded.

Native dumps stay inside PostgreSQL

A direct dump and restore with PostgreSQL's own tools copies the database as stored, including tables, indexes and sequences. It only works when the source is already PostgreSQL, so it does not help with a SQLite or MySQL source. Use it for later moves between PostgreSQL instances or major versions, and follow the upgrade guidance in the PostgreSQL docs for your target version. Confirm that the dump format and restore options match the server version you run.

PostgreSQL upgrade docs

What none of these paths move

Environment variables, secrets and provider settings stay on the old host and must be recreated on the new one. Uploaded files stored on local disk may not follow a database transfer, so confirm where your media lives and whether the storage provider is unchanged. Custom database objects, manual index changes and plugin-specific tables may need separate handling. List every item your project depends on that is outside the content data, and assign each one to a move step before you plan cutover.

Version and engine requirements

Strapi 5 supports PostgreSQL 14 or later, so the target server must meet that minimum before any transfer starts. PostgreSQL 14 is supported until November 12, 2026, so plan a newer major version if the project will run for longer. Keep the Strapi version identical on source and target during the move, and confirm that the Node.js runtime is an Active or Maintenance LTS release. Record these versions in the migration plan so the restore can be repeated later.

Strapi installation requirements

How the SQLite or MySQL to PostgreSQL move runs, from inventory to decommission

The sequence moves a Strapi project from SQLite or MySQL to PostgreSQL in stages, each with a check, so the source database stays available for rollback until the new setup has been verified in use.

  1. Inventory schema, media and environments

    Your team lists the current Strapi version, the source database engine and version, the content types and components, the media storage location, the environment variables, and every environment that points at the database (development, staging, production). The DeployOpen team can review this list with you. Done means you have a written inventory that names each environment, its database, its upload provider and its owner, and that you have confirmed the Strapi version supports PostgreSQL 14 or later as listed in the installation requirements.

  2. Back up the source database first

    Before any export, take a fresh backup of the source database and of the media files it references. This comes first because the source stays in place as your rollback path, and Strapi's upgrade guidance also says to back up the database before changes because downgrades are not supported. Done means the backup has been restored to a scratch location and the restore has been checked by counting rows in the main content and relation tables.

  3. Provision PostgreSQL on a supported major version

    Install a PostgreSQL major version that is still supported on the date you start, and that is at least version 14 for Strapi 5. Choose a version from the supported list in the PostgreSQL versioning policy, and confirm the end-of-support date in the schedule before you choose it. Create a dedicated database, a role with only the privileges Strapi needs, and a test connection from the Strapi host. Done means Strapi's database connection check succeeds against an empty database with the credentials used in production.

  4. Run a pilot import on a copy

    Restore a copy of the production source to a non-production environment, then run the export and import between instances on that copy. Compare record counts, relations, draft and published states, components, and dynamic zones against the source. Record every error and fix it in the export or configuration, not in the live data. Done means a full pilot import completes with no unexplained differences in counts or relations, and the steps are written down so they can be repeated.

  5. Set connection and configuration

    Update the database client, host, port, database name, SSL setting and pool limits in the environment configuration for each non-production environment first. Keep secrets in your secret store, not in the repository. Confirm that the Strapi version and Node.js version in use are on a supported track as listed in the installation requirements. Done means each non-production environment starts cleanly on PostgreSQL and the admin panel loads with the expected content.

  6. Run a parallel check on relations and media

    Keep the old database available and run the new PostgreSQL instance alongside it in a staging environment. Test relations by opening linked entries from both sides, test draft and publish flows, check components and dynamic zones, and confirm that every media item resolves to a working file or URL from the upload provider. Test that scheduled or API-driven changes are written to PostgreSQL. Done means your editors and developers have signed off the checklist, and any defect is fixed and retested.

  7. Cut over with a fresh source backup

    In a short planned window, stop writes to the source, take a new backup of the source database immediately before the switch, run the final export and import, point production configuration at PostgreSQL, and start Strapi. Verify health checks, a sample of relations, and media delivery before you reopen editing. Done means production serves content from PostgreSQL, the final backup is stored and labeled, and the rollback steps are documented and have an owner.

  8. Decommission the old database after verification

    Keep the source database and its backup for an agreed observation period, then remove production write access to it and archive the final backup under your retention policy. Remove unused connection settings and credentials from configuration and secret stores, and update runbooks, monitoring and backup jobs so they cover PostgreSQL only. Done means the old database is no longer referenced by any environment, the backup retention decision is recorded, and monitoring reports the new database as the only source of truth.

Connection settings, PostgreSQL versions and access controls to set before cutover

Choose the PostgreSQL major version before you write any connection settings, because that choice sets your upgrade calendar. Strapi 5 supports PostgreSQL 14 or later, and PostgreSQL 18, 17, 16, 15 and 14 are all listed as supported today. PostgreSQL 14 reaches end of support on November 12, 2026, so a new deployment on 14 would need a major upgrade within a short window. Most teams should start on the newest version their Strapi release and hosting platform accept, then plan the next major upgrade against the published end dates. Confirm the minimum PostgreSQL version and Node.js version for your exact Strapi release in the Strapi installation requirements before you pick.

In the Strapi project, the database settings live in config/database.js (or .ts), where the client is set to postgres and the host, port, database name, schema and credentials are read from environment variables. Enable SSL in that block when the database sits on another host or network segment, and supply the CA certificate your PostgreSQL server uses rather than disabling certificate checks. Create a dedicated database role for Strapi that owns only its schema, with no superuser flag and no rights on other databases. Set password authentication to SCRAM in pg_hba.conf and confirm that MD5 is not used for the Strapi role, since PostgreSQL 18 deprecates MD5 password authentication.

If several Strapi instances, workers or environments connect to the same PostgreSQL server, put PgBouncer or a similar pooler in front of it and size the pool so the total connections from all Strapi processes stay under the server limit. Test the pooler mode with your Strapi version before relying on it, since session-dependent features behave differently under transaction pooling. Confirm every setting with a staging cutover: start Strapi against the new database, check the admin login, and review the connection count under normal load.

How to test relations and media after the database switch

Relations, components and dynamic zones are stored in join and component tables that Strapi builds from your schema, so a move between database engines can change counts, ordering or localized rows without any visible error at startup. Test them against the source system before cutover, using the same content types and a known set of entries. Compare totals per content type first, then spot-check the linked entries that editors rely on most.

  • Record counts per content type: Compare entry counts for drafts and published versions of each type with the source export. A mismatch usually means a skipped batch or a rejected row during import.
  • Linked entries on relations: Open a sample of one-to-many and many-to-many relations and confirm the linked entries and their order. Missing links often show as empty fields rather than errors.
  • Components and dynamic zones: Check that repeatable components keep their item count and sequence, and that every dynamic zone block resolves to the correct component type.
  • Localized versions: For each locale, confirm that the same relations point to the localized entries and that no locale lost its fields.
  • Failed check: A relation that returns null or an empty array in the API while the source shows linked entries, or a dynamic zone that renders blocks in a different order.

Run these checks on a copy of the production data, and record the results so the cutover sign-off has evidence.

What makes the database change cost more or take longer

How many content types and components affect the database change effort?

The schema size drives the mapping work more than the data volume does. Every content type, component, dynamic zone and relation has to be checked after the switch, because Strapi creates its tables from these definitions and the relations between them are where data is most likely to go missing. A project with a small, well-documented schema usually has less to verify than one with many nested components and polymorphic dynamic zones. Ask the vendor to inventory these items before quoting, and to say which ones will get a manual check.

Does the size of the dataset change how long the switch takes?

Yes. Row count and the amount of relation data affect how long the export, import and verification steps run, and they affect how long the source system must stay frozen for a final sync. Large tables with many relations take longer to validate by sampling and by counts. Ask for the current row counts per content type and the expected write rate during cutover, because those two numbers decide whether a short freeze window is realistic in your environment.

How do multiple environments and locales add to the cost?

Each environment (development, staging, production) and each locale multiplies the work. Each one needs its own connection settings, its own import and its own test pass, and locale-specific content must be checked for relation and slug integrity in every language. Plan the order: many teams migrate a non-production copy first, prove the process, then repeat it for production. Ask the vendor whether the quote covers one run or repeated runs for each environment.

Do custom SQL queries or raw database access add effort?

They add effort because Strapi's Document Service and query layer hide the table layout, while custom SQL depends on it. Raw queries written for MySQL or SQLite may use functions, quoting rules or type behavior that PostgreSQL handles differently, so each one needs to be rewritten and tested. Ask for a list of every file that uses knex or raw SQL, and whether any of those queries run in scheduled jobs, which are easy to miss during testing.

Which custom plugins that write to the database raise the risk?

Plugins that write their own tables or store data outside Strapi's normal content APIs need separate review. Their data may not move with a standard export, and their tables may use column types or indexes that need attention on PostgreSQL. Confirm with the plugin authors or in the plugin code which tables are created, and whether the plugin stores media references or settings in the database. Each plugin you cannot verify adds a test item and a potential gap after cutover.

How do media volume and storage location affect the switch?

The database move does not copy uploaded files. Media records in the database point to files in a provider or local folder, so the switch must confirm that every reference still resolves after cutover. Large media libraries, local storage on one host, or a provider with URL rules all add checking work. Ask whether the quote includes asset verification, and who confirms that thumbnails and format variants still load.

Does a rollback window increase the cost?

Yes, because keeping the old database available for a period means running two systems, deciding which one receives writes, and planning how to reconcile edits made during that time. Teams that need to return to MySQL or SQLite quickly usually pay for a longer parallel run and a documented reverse path. Ask the vendor how writes are handled during the rollback window, and who approves the decision to switch back.

Who pays for what in a database change quote, and what recurs afterward?

A written quote should separate the one-time work (assessment, schema review, export and import runs, connection setup, testing, cutover support and documentation) from any recurring work such as hosting the PostgreSQL server, backups, patching and monitoring. Ask which items are fixed and which depend on the counts you supply. Also ask who provisions the PostgreSQL instance, because that cost sits outside the migration itself. Confirm the supported PostgreSQL version with your Strapi version before the quote is finalized, since PostgreSQL 14 support ends on November 12, 2026 according to the PostgreSQL versioning policy.

What usually goes wrong in a Strapi database switch and how to prevent it

Most failed database switches are not crashes. They are imports that finish with missing or altered data, media that no longer resolves, or a target database that the Strapi release does not accept. Each card below names one failure, the step that prevents it and the check that catches it before editors notice.

Import reports success but relations or drafts are missing

A transfer or import can finish without an error while relations between entries, draft versions or unpublished entries are dropped or flattened. Before the switch, count entries per content type, including drafts, in the source and record a few relation paths from a known entry. After the import, repeat the same counts and walk those paths in the admin panel and the API. Any mismatch in counts or broken relation paths means the import is not accepted, whatever the tool reported.

Media records point to missing files

The database holds the media metadata, but the files live in the upload folder or an upload provider. If only the database moves, every image and document record will return a broken URL. Copy the uploads directory or bucket alongside the database, keep the same storage paths, and confirm the upload provider settings in the target environment. Test by opening a sample of images, PDFs and videos from several content types, including ones attached to components and dynamic zones.

PostgreSQL version outside the supported range

Strapi 5 accepts PostgreSQL 14 or later, so the target server must be on a version Strapi supports and that is still receiving PostgreSQL updates. Version 14 is listed as supported until November 12, 2026, so choosing it for a new target means planning an upgrade within a short window. Check the Strapi release you run against the installation requirements, pick a currently supported PostgreSQL major version, and record the version in the change plan so the next major upgrade is scheduled.

Strapi requirements

No verified backup of the source database

A switch that begins without a restorable copy of the SQLite file or the MySQL dump leaves no way back if the import fails partway. Take a full backup of the source database and the upload directory, store it outside the host being changed, and test that it restores to a scratch instance. Keep the source running read-only until the PostgreSQL instance has passed the content and media checks. The supplied Strapi guidance stresses backing up the database before upgrades because downgrades are not supported.

Connection string and SSL errors

Strapi reads the database client, host, port, name, user, password and SSL settings from environment variables. A missing SSL mode, a certificate path that exists only on the old host, or a password with characters that break URL parsing can make the server start against the wrong database or fail only under load. Set the connection values from a secrets store, set the SSL mode the server requires, and confirm with a fresh start that Strapi reports the PostgreSQL client. Then run a write and read test from each application node.

Sequence and ID mismatches after import

PostgreSQL uses sequences to assign new IDs. If rows are loaded with explicit IDs and the sequences are not advanced, the next insert can collide with an existing ID or fail on a unique key. Editors then see errors only when they create new content. After loading, compare each table's maximum ID with its sequence's current value and reset any sequence that lags. Test by creating an entry, a media item and a relation in the admin panel, then deleting them.

Questions teams ask before changing a Strapi database to PostgreSQL

How much effort and cost does moving Strapi from SQLite or MySQL to PostgreSQL involve?

The work is usually modest in code but real in verification, and the cost comes mostly from people hours rather than software. Cost components are the engineer time to prepare the target database, run the export and import, adjust connection settings, and test relations and media, plus any infrastructure for a new PostgreSQL server. The main drivers are the size of the content model, the number of relations and components, how much media sits in local storage, whether custom code writes raw SQL, and how many environments need the change. Recurring costs are the database hosting and the patching routine after the move. Ask any quote to itemize these components and state which environments and data volumes it covers.

How long does a database engine change take for a Strapi project?

Duration depends on the project's size, its custom code and how many environments must move, and no researched figure is available to quote here. A small project with a simple content model and a single environment is a different exercise from a multi-environment project with custom services and a large media library. Ask for the planned sequence: a dry run on a copy, a timed export and import, a list of test cases for relations and media, and a cutover window. Confirm with the team who owns the content freeze and the acceptance criteria before the calendar is set.

What must our team provide before the database change starts?

The team must provide access and a clear picture of the running system. That means the current database and Strapi version, the Node.js version in use, hosting details for the target PostgreSQL server, a list of environment variables and database settings, and a full backup of the source database. The team also needs a named owner who can approve the content freeze, a staging environment that mirrors production, and access to the media storage location. Confirm the exact Strapi version first, because the supported database list and Node.js rules depend on it.

Can our in-house team change the Strapi database without an outside partner?

An in-house team with Strapi and PostgreSQL experience can do this work, and many do. The skills needed are configuring the database client settings, running the export and import tooling, checking data types and relations after the move, and operating a PostgreSQL server. Teams without a PostgreSQL administrator often find the operating side, such as backups, access control and high availability, takes the most time. DeployOpen can scope and carry out the change as a fixed-scope engagement if the in-house team lacks capacity. Confirm the skills available before choosing.

Is there a rollback path if the PostgreSQL move fails?

Yes, but only if the source database is preserved and the team keeps it untouched until acceptance. Take a full backup of the source database before the change and keep the original SQLite file or MySQL database available for the agreed period. Rollback means pointing Strapi's database settings back to the source and restoring any content written during a short parallel window, which is why a content freeze matters. Strapi's own migration docs warn that downgrades are not supported in the v4 to v5 path, so do not assume a version rollback is possible. Ask the team to write down the rollback steps and test them on staging.

Do PostgreSQL's license and support window affect this choice?

PostgreSQL's license is permissive, so using it does not add a license fee or copyleft obligation to your Strapi project. Its support window does matter for planning. Per the PostgreSQL versioning policy, version 14 is supported until November 12, 2026, while 18 runs to November 14, 2030, so a new deployment should target a version with a longer window. Strapi 5 supports PostgreSQL 14 or later. Confirm the version you target against the current versioning page and plan the next major upgrade before it is needed.

Which Strapi database settings and tests matter most after the switch?

Engineers should check the connection settings, relation integrity and media links before declaring the move complete. For connections, confirm the client type, host, port, database name, credentials, SSL settings and pool size in the environment configuration, and verify that the admin panel and API both start. For data, compare entry counts per content type, sample one-to-many and many-to-many relations, check components and dynamic zones, and confirm that media files resolve from their stored URLs. Also test scheduled jobs and any custom queries, because raw SQL written for MySQL or SQLite may behave differently on PostgreSQL.

How the source database, export, PostgreSQL target and media store fit during the switch

The switch starts with the existing Strapi project on SQLite or MySQL, which is exported or transferred into a fresh Strapi instance connected to PostgreSQL. Media files move separately to the store the target uses, and connection settings point the new instance at the right database and assets. Before cutover, relations and media are tested, and the original database stays untouched until those checks pass.

Phased switch from SQLite or MySQL to PostgreSQL, with the old database kept until tests pass.

How DeployOpen scopes and delivers a Strapi database migration

DeployOpen treats the move from SQLite or MySQL to PostgreSQL as a fixed-scope piece of work with a written plan, a rehearsed cutover and evidence for each check. The work runs in infrastructure you control, so the database, the Strapi instance and the media store stay under your governance from start to finish.

How we scope

  • Confirm the current Strapi version, source database engine and version, and the Node.js version in use before any work starts.
  • Agree in writing which PostgreSQL major version is targeted, checked against the supported version list at the time of the work.
  • Record which content types, components, relations, media fields and custom queries must be verified after the switch.

How we build

  • Set up a non-production PostgreSQL instance with connection settings, credentials and TLS choices matching your security standards.
  • Rehearse the export and import between instances, then compare record counts, relations and media references against the source.
  • Document the connection configuration, environment variables and any changes to deployment templates for your team to review.

How we hand over

  • Deliver a cutover runbook with the backup taken before the switch, the freeze window, rollback steps and sign-off points.
  • Provide a test report covering relations, localized entries, draft and publish states, and media files after the move.
  • Train your engineers on routine operations, including backups, restores and how to read database logs for the new instance.

How we support

  • Engagements are fixed-scope, so scope changes such as additional content types or extra environments are quoted in writing.
  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Ask us to confirm the PostgreSQL support window and your Strapi upgrade plan so the database remains on a supported release.

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.