Skip to main content

v4.7.0 to v4.11.4 migration guide

The Strapi v4.7.0 to v4.11.4 migration guide upgrades v4.7.0 to v4.11.4. We updated how images are fetched in the Media Library, and some people had database records in the wrong state from old migrations. The migration guide consists of:

  • Upgrading the application dependencies
  • Installing database migration script (Optional)
  • Reinitializing the application
Caution

Plugins extension that create custom code or modify existing code, will need to be updated and compared to the changes in the repository. Not updating the plugin extensions could break the application.

Upgrading the application dependencies to 4.11.4

☑️ Prerequisites

Stop the server before starting the upgrade.

  1. Upgrade all of the Strapi packages in package.json to 4.11.4:

    path: package.json
    {
    // ...
    "dependencies": {
    "@strapi/strapi": "4.11.4",
    "@strapi/plugin-users-permissions": "4.11.4",
    "@strapi/plugin-i18n": "4.11.4"
    // ...
    }
    }
  2. Save the edited package.json file.

  3. Run the install command:

    Install the upgraded version:

    yarn
    💡 Tip

    If the operation doesn't work, try removing your yarn.lock or package-lock.json. If that doesn't help, remove the node_modules folder as well and try again.

Installing database migration script (Optional)

Skip this step if you can see all images in your Media Library after updating to 4.11.4 or greater.

The issue with missing images in the Media Library is documented here. In version 4.11.4, the Media Library fetches files by their folder path. Root files should have a / path. Some users migrating from older versions had NULL values for root files' folder paths, causing the Media Library to appear empty. This migration updates those files folder paths to /.

To prepare the migration:

  1. Make a backup of the database in case something unexpected happens.
  2. In the ./database/migrations folder, create a file named 2023.06.14T00.00.00.update-file-paths.js.
  3. Copy and paste the following code into the previously created file:
"use strict";

const FILE_TABLE = "files";

async function up(trx) {
// Updates file
await trx
.from(FILE_TABLE)
.whereNull("folder_path")
.update({ folder_path: "/" });
}

async function down() {}

module.exports = { up, down };
  1. Save the file.

Rebuild the application

Run the following command in your project root directory to rebuild Strapi's admin panel:

yarn build

Restart the application

Run the following command in your project root directory to restart the application:

yarn develop