diff --git a/docs/.vuepress/config/plugins.js b/docs/.vuepress/config/plugins.js index 467b7821a9..58c96a2027 100644 --- a/docs/.vuepress/config/plugins.js +++ b/docs/.vuepress/config/plugins.js @@ -43,6 +43,12 @@ const plugins = [ }, ], ['@vuepress/back-to-top', {}], + [ + '@vuepress/html-redirect', + { + duration: 0, + }, + ], [ 'vuepress-plugin-container', { @@ -149,25 +155,29 @@ const plugins = [ type: 'grid', defaultTitle: '', }, - ], [ + ], + [ 'vuepress-plugin-container', { type: 'grid-top-left', defaultTitle: '', }, - ], [ + ], + [ 'vuepress-plugin-container', { type: 'grid-top-right', defaultTitle: '', }, - ], [ + ], + [ 'vuepress-plugin-container', { type: 'grid-bottom-left', defaultTitle: '', }, - ], [ + ], + [ 'vuepress-plugin-container', { type: 'grid-bottom-right', diff --git a/docs/.vuepress/redirects b/docs/.vuepress/redirects new file mode 100644 index 0000000000..73b7a11d68 --- /dev/null +++ b/docs/.vuepress/redirects @@ -0,0 +1,2 @@ +/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to4.0.6.html /developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.0+-to-4.0.6.html +/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to-4.1.8.html /developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.6+-to-4.1.8.html diff --git a/docs/developer-docs/latest/update-migration-guides/migration-guides.md b/docs/developer-docs/latest/update-migration-guides/migration-guides.md index 3676335cd7..d69423318b 100644 --- a/docs/developer-docs/latest/update-migration-guides/migration-guides.md +++ b/docs/developer-docs/latest/update-migration-guides/migration-guides.md @@ -15,8 +15,9 @@ Migrations are necessary when upgrades to Strapi include breaking changes. The m ## v4 migration guides -- [Migration guide from 4.0.x to 4.0.6](migration-guides/v4/migration-guide-4.0.x-to4.0.6.md) -- [Migration guide from 4.0.6 to 4.1.8](migration-guides/v4/migration-guide-4.0.x-to-4.1.8.md) +- [Migration guide from 4.0.0+ to 4.0.6](migration-guides/v4/migration-guide-4.0.0+-to-4.0.6.md) +- [Migration guide from 4.0.6+ to 4.1.8](migration-guides/v4/migration-guide-4.0.6+-to-4.1.8.md) +- [Migration guide from 4.1.8+ to 4.1.10](migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md) ## v3 to v4 migration guides diff --git a/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to4.0.6.md b/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.0+-to-4.0.6.md similarity index 76% rename from docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to4.0.6.md rename to docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.0+-to-4.0.6.md index f6f626f21e..4dc000cfd9 100644 --- a/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to4.0.6.md +++ b/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.0+-to-4.0.6.md @@ -1,12 +1,12 @@ --- -title: Migrate from 4.0.5 to 4.0.6 - Strapi Developer Docs -description: Learn how you can migrate your Strapi application from 4.0.5 to 4.0.6. +title: Migrate from 4.0.0+ to 4.0.6 - Strapi Developer Docs +description: Learn how you can migrate your Strapi application from 4.0.0+ to 4.0.6. canonicalUrl: https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to4.0.6.html --- -# v4.0.x to v4.0.6 migration guide +# v4.0.0+ to v4.0.6 migration guide -The Strapi v4.0.x to v4.0.6 migration guide upgrades all prior versions of v4.0.x to v4.0.6. The migration adds the `session` middleware to the middleware array and configures the `session` middleware. The `session` middleware is based on [koa-session](/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.md#session) and is necessary to fix the login provider feature of the [Users & Permissions plugin](/developer-docs/latest/plugins/users-permissions.md). Additionally, password protection in the [Documentation plugin](/developer-docs/latest/plugins/documentation.md) uses the `session` middleware. The migration guide consists of 3 sections: +The Strapi v4.0.0+ to v4.0.6 migration guide upgrades versions of v4.0.0 and above to v4.0.6. The migration adds the `session` middleware to the middleware array and configures the `session` middleware. The `session` middleware is based on [koa-session](/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.md#session) and is necessary to fix the login provider feature of the [Users & Permissions plugin](/developer-docs/latest/plugins/users-permissions.md). Additionally, password protection in the [Documentation plugin](/developer-docs/latest/plugins/documentation.md) uses the `session` middleware. The migration guide consists of 3 sections: - upgrading the application dependencies - migrating the breaking changes to the middleware @@ -79,7 +79,7 @@ It is a security risk to expose static session middleware keys in a deployed env ```js APP_KEYS=[someSecret, anotherSecret, additionalSecrets] -or +or APP_KEYS=someSecret,anotherSecret,additionalSecrets ``` diff --git a/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to-4.1.8.md b/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.6+-to-4.1.8.md similarity index 81% rename from docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to-4.1.8.md rename to docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.6+-to-4.1.8.md index 0a851ce4e9..325ffaff85 100644 --- a/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to-4.1.8.md +++ b/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.6+-to-4.1.8.md @@ -1,14 +1,17 @@ --- -title: Migrate from 4.1.7 to 4.1.8 - Strapi Developer Docs -description: Learn how you can migrate your Strapi application from 4.1.7 to 4.1.8. +title: Migrate from 4.0.6+ to 4.1.8 - Strapi Developer Docs +description: Learn how you can migrate your Strapi application from 4.0.6+ to 4.1.8. canonicalUrl: https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.0.x-to-4.1.8.html --- -# v4.0.x to v4.1.8 migration guide +# v4.0.6+ to v4.1.8 migration guide -The Strapi v4.0.x to v4.1.8 migration guide upgrades versions of v4.0.6 through v4.1.7 to v4.1.8. The minimum configuration for `config/admin` now includes the API token `API_TOKEN_SALT`. Strapi no longer populates default values for the admin JWT in `config/admin`. Initial values are generated and stored in the .env file during project creation. Strapi no longer passes secrets to non-development environments, requiring users to set the secrets purposefully. The migration to v4.1.8 consists of 4 steps: +The Strapi v4.0.6+ to v4.1.8 migration guide upgrades versions of v4.0.6 and above to v4.1.8. The minimum configuration for `config/admin` now includes the API token `API_TOKEN_SALT`. Strapi no longer populates default values for the admin JWT in `config/admin`. Initial values are generated and stored in the .env file during project creation. Strapi no longer passes secrets to non-development environments, requiring users to set the secrets purposefully. The migration to v4.1.8 consists of 4 steps: -- upgrading the application dependencies +- Upgrading the application dependencies +- Fixing the breaking changes +- Setting secrets for non-development environments +- Reinitializing the application ## Upgrading the application dependencies to 4.1.8 diff --git a/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md b/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md new file mode 100644 index 0000000000..0330ad9030 --- /dev/null +++ b/docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md @@ -0,0 +1,102 @@ +--- +title: Migrate from 4.1.8+ to 4.1.10 - Strapi Developer Docs +description: Learn how you can migrate your Strapi application from 4.1.8+ to 4.1.10. +canonicalUrl: https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.html +--- + +# v4.1.8+ to v4.1.10 migration guide + +The Strapi v4.1.8+ to v4.1.10 migration guide upgrades versions of v4.1.8 and above to v4.1.10. This migration guide is needed only for users who experienced missing MIME types on their media when uploading media through the Content API (see [GitHub issue #12761](https://github.com/strapi/strapi/issues/12761)). The migration to 4.1.10 consists of 3 steps: + +- Upgrading the application dependencies +- Installing database migration script (optional) +- Reinitializing the application + +## Upgrading the application dependencies to 4.1.10 + +:::prerequisites +Stop the server before starting the upgrade. +::: + +1. Upgrade all of the Strapi packages in the `package.json` to `4.1.10`: + +```jsx +// path: package.json + +{ + // ... + "dependencies": { + "@strapi/strapi": "4.1.10", + "@strapi/plugin-users-permissions": "4.1.10", + "@strapi/plugin-i18n": "4.1.10", + // ... + } +} + +``` + +2. Save the edited `package.json` file. + +3. Run either `yarn` or `npm install` to install the new version. + +::: 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) + +This step is only required if some files in your database have their MIME type set to `null` (see GitHub issue [#12761](https://github.com/strapi/strapi/issues/12761)). + +To make sure Strapi can load the Media Library, the following migration script file must be added to `./database/migrations`. The script automatically sets MIME types for files that miss one, based on their filename. The script will be automatically executed only once at the next launch of Strapi. + +To add the script: + +1. In the `./database/migrations` folder, create a file named `2022.05.10T00.00.00.fill-files-mime-type.js`. +2. Copy and paste the following code into the previously created file: + +```jsx +'use strict' + +// path: database/migrations + +const mimeTypes = require('mime-types'); + +const BATCH_SIZE = 1000; +const FILE_TABLE = 'files'; + +async function up(trx) { + let lastId = 0; + while (true) { + const files = await trx + .select(['id', 'name']) + .from(FILE_TABLE) + .where('mime', null) + .andWhere('id', '>', lastId) + .orderBy('id', 'asc') + .limit(BATCH_SIZE); + + const mimesMap = {}; + for (let file of files) { + const mime = mimeTypes.lookup(file.name) || 'application/octet-stream'; + mimesMap[mime] = mimesMap[mime] || []; + mimesMap[mime].push(file.id); + } + + for (let mime of Object.keys(mimesMap)) { + await trx.update({ mime }).from(FILE_TABLE).whereIn('id', mimesMap[mime]); + } + + if (files.length < BATCH_SIZE) { + break; + } + + lastId = files[files.length - 1].id; + } +} + +async function down() {} + +module.exports = { up, down }; +``` + +!!!include(developer-docs/latest/update-migration-guides/migration-guides/v4/snippets/Rebuild-and-start-snippet.md)!!! diff --git a/docs/package.json b/docs/package.json index 427d104254..08eebb9771 100644 --- a/docs/package.json +++ b/docs/package.json @@ -13,6 +13,7 @@ "create:user-config-file": "node ./scripts/create-user-docs-config-file.js" }, "dependencies": { + "@vuepress/plugin-html-redirect": "^0.1.4", "@vuepress/plugin-medium-zoom": "^1.8.2", "markdown-it-include": "^2.0.0", "vuepress": "^1.8.2", diff --git a/docs/yarn.lock b/docs/yarn.lock index 0616e7ecc1..f5c814459a 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -1206,6 +1206,11 @@ dependencies: lodash.debounce "^4.0.8" +"@vuepress/plugin-html-redirect@^0.1.4": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-html-redirect/-/plugin-html-redirect-0.1.4.tgz#019a3d9ffe1af0f7421ca3b841b276a03a74b320" + integrity sha512-tzVquctn7Jwv/nFlsbDxqUeaJzG5H+muoOWl1O3M24XFu3KVsIoqZZt1seawrSCWWfFyLB9nVPJSoXALQ62hdg== + "@vuepress/plugin-last-updated@1.8.2": version "1.8.2" resolved "https://registry.yarnpkg.com/@vuepress/plugin-last-updated/-/plugin-last-updated-1.8.2.tgz#7ce689f8d5050cf0213949bc2e5aa879c09ff4b1"