diff --git a/docs/en/04_Changelogs/4.7.0.md b/docs/en/04_Changelogs/4.7.0.md index 783886ce3..e918d5fb4 100644 --- a/docs/en/04_Changelogs/4.7.0.md +++ b/docs/en/04_Changelogs/4.7.0.md @@ -113,6 +113,16 @@ remove the new collation configuration to default back to the previous default c In MySQL versions >=5.7.5, the `ANSI` sql_mode setting behaves differently and includes the `ONLY_FULL_GROUP_BY` setting. It is generally recommended to leave this setting as-is because it results in deterministic SQL. However, for some advanced cases, the sql_mode can now be configured on the database connection via the configuration API (see `MySQLDatabase::$sql_mode` for more details.) +### MySQL/MariaDB Int width in schema +MySQL 8.0.17 stopped reporting the width attribute for integers while MariaDB did not change its behaviour. +This results in constant rebuilding the schema when MySQLSchemaManager expects a field to look like i.e. +`INT(8)` and MySQL server reports it simply as `INT`. MySQLSchemaManager has been updated to detect the MySQL +server implementation and act accordingly. In cases when auto-detection fails, you can force the desired behaviour like this: +```yml +SilverStripe\ORM\Connect\MySQLSchemaManager: + schema_use_int_width: true # or false when INT widths should be ignored +``` + ### Flysystem dependency shifted Previously the Flysystem package was pulled in via the `silverstripe/framework` module, but only diff --git a/src/ORM/Connect/MySQLSchemaManager.php b/src/ORM/Connect/MySQLSchemaManager.php index 16b7a0992..b886076c7 100644 --- a/src/ORM/Connect/MySQLSchemaManager.php +++ b/src/ORM/Connect/MySQLSchemaManager.php @@ -246,6 +246,10 @@ class MySQLSchemaManager extends DBSchemaManager // MySQL 8.0.17 stopped reporting the width attribute for integers // https://github.com/silverstripe/silverstripe-framework/issues/9453 // Note: MariaDB did not change its behaviour + $forceWidth = Config::inst()->get(self::class, 'schema_use_int_width'); + if ($forceWidth !== null) { + return $forceWidth; + } $v = $this->database->getVersion(); if (false !== strpos($v, 'MariaDB')) { // MariaDB is included in the version string: https://mariadb.com/kb/en/version/