-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration guide to 4.1.10 (#885)
* add migration guide to 4.1.10 * Update file name * Update docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md Co-authored-by: Pierre Wizla <[email protected]> * Update docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md Co-authored-by: Pierre Wizla <[email protected]> * Update docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md Co-authored-by: Pierre Wizla <[email protected]> * Update docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md Co-authored-by: Pierre Wizla <[email protected]> * Update docs/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md Co-authored-by: Pierre Wizla <[email protected]> * Add redirects plugin and rename v4 migration guides to match new std Co-authored-by: Pierre Wizla <[email protected]> Co-authored-by: derrickmehaffy <[email protected]>
- Loading branch information
1 parent
596e55b
commit cfaae3e
Showing
8 changed files
with
140 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
...ides/v4/migration-guide-4.0.x-to-4.1.8.md → ...des/v4/migration-guide-4.0.6+-to-4.1.8.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...update-migration-guides/migration-guides/v4/migration-guide-4.1.8+-to-4.1.10.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | ||
``` | ||
|
||
!!!include(developer-docs/latest/update-migration-guides/migration-guides/v4/snippets/Rebuild-and-start-snippet.md)!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|