You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/5.x/upgrade.md
+33-13Lines changed: 33 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Take a peek at what’s new in Craft 5.
5
5
6
6
# Upgrading from Craft 4
7
7
8
-
The smoothest way to upgrade to Craft 5 is to start with a [fully-updated Craft 4 project](/4.x/updating.md).
8
+
The smoothest way to upgrade to Craft 5 is to start with a [fully-updated Craft 4 project](/4.x/updating.md). We recommend approaching the upgrade in three phases: [preparation](#preparing-for-the-upgrade), a [local upgrade](#performing-the-upgrade), and [rollout](#going-live) to live environments.
9
9
10
10
<!-- more -->
11
11
@@ -54,14 +54,14 @@ ddev start
54
54
1. Run `php craft project-config/rebuild` and allow any new background tasks to complete.
55
55
1. Capture a database backup of your _local_ environment, just in case things go sideways.
56
56
1. Note your current **Temp Uploads Location** setting in **Settings**→**Assets**→**Settings**.
57
-
1. Add your database’s current character set and collation to `.env`. If you have always used Craft’s defaults, this will be:
57
+
1.MySQL users: Add your database’s _current_ character set and collation to `.env`. If you have always used Craft’s defaults, this will be:
58
58
59
59
```bash
60
60
CRAFT_DB_CHARSET="utf8mb3"
61
61
CRAFT_DB_COLLATION="utf8mb3_general_ci"
62
62
```
63
63
64
-
If you _have_ changed the character set or collation, make sure your settings agree with [these recommendations](#database-character-set-and-collation).
64
+
Read more about this process in the [Database Character Set and Collation](#database-character-set-and-collation) section, below.
65
65
66
66
1. Edit your project’s `composer.json` to require `"craftcms/cms": "^5.0.0"` and Craft-5-compatible plugins, all at once.
67
67
@@ -70,26 +70,39 @@ ddev start
70
70
:::
71
71
72
72
While you’re at it, review your project’s [other dependencies](#entry-scripts)! You may also need to add `"php": "8.2"` to your [platform](https://getcomposer.org/doc/06-config.md#platform) requirements, or remove it altogether.
73
+
73
74
1. Run `composer update`.
74
75
1. Make any required changes to your [configuration](#configuration).
75
76
1. Run `php craft up`.
76
-
1. Remove your database character set and collation settings from `.env` (and `db.php`—even if you didn’t modify it during the upgrade), then run `php craft db/convert-charset`.
77
+
1. MySQL users: Remove your database character set and collation settings from `.env` (and `db.php`—even if you didn’t modify it during the upgrade), then run `php craft db/convert-charset`.
77
78
78
79
Your site is now running Craft 5! If you began this process with no deprecation warnings, you’re nearly done.
79
80
80
81
::: warning
81
82
Thoroughly review the list of changes on this page, making note of any features you use in templates or modules. Only a fraction of your site’s code is actually evaluated during an upgrade, so it’s your responsibility to check templates and modules for consistency. You may also need to follow any plugin-specific upgrade guides.
82
83
:::
83
84
84
-
Once you’ve verified everything’s in order, commit your updated `composer.json`, `composer.lock`, and `config/project/` directory (along with any template, configuration, or module files that required updates) and deploy those changes normally in each additional environment.
85
+
## Going Live
86
+
87
+
The Craft 5 upgrade can be run largely unattended during a routine deployment. Once you’ve performed the upgrade in your local environment and everything is working as expected, commit your updated `composer.json`, `composer.lock`, and `config/project/` directory, as well as any template, configuration, or module files that required updates.
88
+
89
+
::: warning
90
+
MySQL users must add the correct [character set and collation settings](#database-character-set-and-collation) to each remote environment for the duration of the upgrade.
91
+
:::
92
+
93
+
Deploy your changes to each environment, then run `php craft up`.
94
+
95
+
If you added temporary character set or collation settings for the upgrade, remove them now, then run `php craft db/convert-charset` to apply Craft 5’s new defaults to all tables.
96
+
97
+
Read more about this part of the upgrade in the [Database Character Set and Collation](#database-character-set-and-collation) section, below.
85
98
86
-
### Cleanup + Optional Steps
99
+
## Cleanup + Optional Steps
87
100
88
101
#### Entry Scripts
89
102
90
103
Older projects may use versions of [`vlucas/phpdotenv`](repo:vlucas/phpdotenv) (the library that loads variables from your `.env` file) that depend on features deprecated in PHP 8.1. If you encounter errors during (or after) installation, change your `vlucas/phpdotenv` dependency in`composer.json` to `^5.6.0`, then run `composer update`.
91
104
92
-
Along with this update, you’ll need to integrate changes from our [starter project](repo:craftcms/craft)’s `web/index.php` script and `craft` executable. If you have done any low-level customization of Craft via [bootstrap constants](configure.md#bootstrap-config), make sure those values are preserved in the appropriate file(s)—constants shared between the two files can be moved to the new [`bootstrap.php` file](repo:craftcms/craft/blob/5.x/bootstrap.php).
105
+
Along with this update, you’ll need to integrate changes from our [starter project](repo:craftcms/craft)’s `web/index.php` script and `craft` executable. If you have done any low-level customization of Craft via [bootstrap constants](configure.md#bootstrap-config), make sure those values are preserved in the appropriate file(s)—constants shared between the two files can be moved to a common [`bootstrap.php` file](repo:craftcms/craft/blob/5.x/bootstrap.php).
93
106
94
107
## Breaking Changes and Deprecations
95
108
@@ -107,26 +120,33 @@ The following settings have been changed.
107
120
108
121
MySQL 8.0 [deprecated the `utf8mb3` character set](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html), as well as [the use of `utf8` as an aliasfor`utf8mb3`](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html). MySQL [recommends `utf8mb4`](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb4.html) instead, and it’s expected that `utf8` will become an alias for `utf8mb4`in MySQL 8.1.
109
122
110
-
To ease that transition, Craft 5 is proactively treating `utf8` as `utf8mb4`for MySQL and MariaDB installs. Since that will be different from what most Craft installs are already using, you will need to start explicitly setting the charset and collation using the non-aliased names, to avoid a SQL error during the upgrade.
123
+
To ease that transition, Craft 5 is proactively treating `utf8` as `utf8mb4`for MySQL and MariaDB installs.
111
124
112
-
Ensure the following are setin your `.env` file:
125
+
<Block label="During the Upgrade">
126
+
127
+
Explicitly setting the character set and collation ensures compatibility of new tables _during_ the upgrade—afterwards, those settings can be scrubbed and the tables can be converted via Craft’s CLI. Here’s how this will look, in practice.
128
+
129
+
If you have never customized character set or collation settings foryour database connection, set these variablesin your `.env` file during the upgrade:
113
130
114
131
```bash
115
132
CRAFT_DB_CHARSET="utf8mb3"
116
133
CRAFT_DB_COLLATION="utf8mb3_general_ci"
117
134
```
118
135
119
-
::: tip
120
-
Once the upgrade is complete, you can convert your tables to `utf8mb4` by removing the `CRAFT_DB_CHARSET` and `CRAFT_DB_COLLATION` environment variables, or updating them to the appropriate values:
136
+
If you _are_ using these settings (either from `.env` or `db.php`), they can be left as-is, for now.
137
+
138
+
Once the upgrade is completein an environment, convert your tables to `utf8mb4` by _removing_ the `CRAFT_DB_CHARSET` and `CRAFT_DB_COLLATION` environment variables (and clearing any `charset` and `collation` settings from `db.php`)…
121
139
122
140
```bash
141
+
# …or set them to Craft’s defaults…
123
142
CRAFT_DB_CHARSET="utf8mb4"
124
143
CRAFT_DB_COLLATION="utf8mb4_0900_ai_ci"# MySQL
125
144
CRAFT_DB_COLLATION="utf8mb4_unicode_ci" # MariaDB
126
145
```
127
146
128
-
Then run `php craft db/convert-charset` to update all existing database tables.
0 commit comments