Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migration guide to 4.1.10 #885

Merged
merged 8 commits into from
May 11, 2022
18 changes: 14 additions & 4 deletions docs/.vuepress/config/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ const plugins = [
},
],
['@vuepress/back-to-top', {}],
[
'@vuepress/html-redirect',
{
duration: 0,
},
],
[
'vuepress-plugin-container',
{
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions docs/.vuepress/redirects
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
```
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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 };
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexandrebodin If you want to review the script

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the script looks good to me


!!!include(developer-docs/latest/update-migration-guides/migration-guides/v4/snippets/Rebuild-and-start-snippet.md)!!!
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "1.8.2"
resolved "https://registry.yarnpkg.com/@vuepress/plugin-last-updated/-/plugin-last-updated-1.8.2.tgz#7ce689f8d5050cf0213949bc2e5aa879c09ff4b1"
Expand Down