-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
+140
−16
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5888d52
add migration guide to 4.1.10
petersg83 403c2fe
Update file name
pwizla 41402ee
Update docs/developer-docs/latest/update-migration-guides/migration-g…
petersg83 b186d88
Update docs/developer-docs/latest/update-migration-guides/migration-g…
petersg83 61568a4
Update docs/developer-docs/latest/update-migration-guides/migration-g…
petersg83 1a09e45
Update docs/developer-docs/latest/update-migration-guides/migration-g…
petersg83 5b642e1
Update docs/developer-docs/latest/update-migration-guides/migration-g…
petersg83 a142a94
Add redirects plugin and rename v4 migration guides to match new std
derrickmehaffy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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