|
| 1 | +--- |
| 2 | +title: Migrate from 4.7.1+ to 4.11.0 |
| 3 | +description: Learn how you can migrate your Strapi application from 4.7.1+ to 4.11.0. |
| 4 | +displayed_sidebar: devDocsSidebar |
| 5 | +--- |
| 6 | + |
| 7 | +import BuildCommand from '/docs/snippets/build-npm-yarn.md' |
| 8 | +import DevelopCommand from '/docs/snippets/develop-npm-yarn.md' |
| 9 | + |
| 10 | +# v4.10.1+ to v4.11.0 migration guide |
| 11 | + |
| 12 | +The Strapi v4.10.1+ to v4.11.0 migration guide upgrades v4.10.1+ to v4.11.0. |
| 13 | + |
| 14 | +:::note |
| 15 | +This migration guide is optional and only concerns Strapi projects that are currently accepting additional, custom user fields (i.e., other than the email, username, and password fields) on their [Users and Permissions plugin](/dev-docs/plugins/users-permissions) registration system. |
| 16 | +::: |
| 17 | + |
| 18 | +In Strapi v4.11+, the new user registration system in the Users & Permissions plugin only accepts email, username, and password fields by default. If your Strapi application has added any other custom user fields that your new registration form needs to accept, you must add them to the `allowedFields` configuration. |
| 19 | + |
| 20 | +The migration guide consists of: |
| 21 | + |
| 22 | +- Upgrading the application dependencies |
| 23 | +- Adding the additional custom fields to allow in the Users & Permissions plugin |
| 24 | +- Reinitializing the application |
| 25 | + |
| 26 | +## Upgrading the application dependencies to 4.11.0 |
| 27 | + |
| 28 | +:::prerequisites |
| 29 | +Stop the server before starting the upgrade. |
| 30 | +::: |
| 31 | + |
| 32 | +1. Upgrade all of the Strapi packages in `package.json` to `4.11.0`: |
| 33 | + |
| 34 | + ```json title="package.json" |
| 35 | + |
| 36 | + { |
| 37 | + // ... |
| 38 | + "dependencies": { |
| 39 | + "@strapi/strapi": "4.11.0", |
| 40 | + "@strapi/plugin-users-permissions": "4.11.0", |
| 41 | + "@strapi/plugin-i18n": "4.11.0" |
| 42 | + // ... |
| 43 | + } |
| 44 | + } |
| 45 | + ``` |
| 46 | + |
| 47 | +2. Save the edited `package.json` file. |
| 48 | + |
| 49 | +3. Run either `yarn` or `npm install` to install the new version. |
| 50 | + |
| 51 | +:::tip |
| 52 | +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. |
| 53 | +::: |
| 54 | + |
| 55 | +## Allow additional custom fields in the Users & Permissions plugin registration |
| 56 | + |
| 57 | +The Users & Permissions plugin registration system in Strapi v4.11 only accepts email, username, and password fields by default. If additional fields were added to your user model and need to be accepted on registration, add these fields to the `allowedFields` in the `register` configuration option, otherwise the fields will be ignored. |
| 58 | + |
| 59 | +For example, if you have added a field called `nickname` that you wish to accept from the user, update your configuration object as follows: |
| 60 | + |
| 61 | +<Tabs groupId="js-ts"> |
| 62 | + |
| 63 | +<TabItem value="javascript" label="JavaScript"> |
| 64 | + |
| 65 | +```js title="./config/plugins.js" |
| 66 | +module.exports = ({ env }) => ({ |
| 67 | + // ... |
| 68 | + "users-permissions": { |
| 69 | + config: { |
| 70 | + register: { |
| 71 | + allowedFields: ["nickname"], |
| 72 | + }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + // ... |
| 76 | +}); |
| 77 | +``` |
| 78 | + |
| 79 | +</TabItem> |
| 80 | + |
| 81 | +<TabItem value="typescript" label="TypeScript"> |
| 82 | + |
| 83 | +```ts title="./config/plugins.ts" |
| 84 | +export default ({ env }) => ({ |
| 85 | + // ... |
| 86 | + "users-permissions": { |
| 87 | + config: { |
| 88 | + register: { |
| 89 | + allowedFields: ["nickname"], |
| 90 | + }, |
| 91 | + }, |
| 92 | + }, |
| 93 | + // ... |
| 94 | +}); |
| 95 | +``` |
| 96 | + |
| 97 | +</TabItem> |
| 98 | + |
| 99 | +</Tabs> |
| 100 | + |
| 101 | +## Rebuild the application |
| 102 | + |
| 103 | +<BuildCommand components={props.components} /> |
| 104 | + |
| 105 | +## Restart the application |
| 106 | + |
| 107 | +<DevelopCommand components={props.components} /> |
0 commit comments