diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index a3b7542e4..a24d4ac4c 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -7,6 +7,12 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. * The Vagrant file and all its assets have been removed. +**Database Schema** + +* Please apply the `v2.11.0.sql` upgrade script depending on your database vendor. + In package installations this file can be found in `/usr/share/doc/icingaweb2/schema/*-upgrades/` + (Debian/Ubuntu: `/usr/share/icingaweb2/etc/schema/*-upgrades/`). + ## Upgrading to Icinga Web 2 2.10.x **General** diff --git a/etc/schema/mysql-upgrades/2.11.0.sql b/etc/schema/mysql-upgrades/2.11.0.sql new file mode 100644 index 000000000..d55d563d7 --- /dev/null +++ b/etc/schema/mysql-upgrades/2.11.0.sql @@ -0,0 +1,16 @@ +ALTER TABLE `icingaweb_group` CONVERT TO CHARACTER SET utf8mb4; +ALTER TABLE `icingaweb_group_membership` CONVERT TO CHARACTER SET utf8mb4; +ALTER TABLE `icingaweb_user` CONVERT TO CHARACTER SET utf8mb4; +ALTER TABLE `icingaweb_user_preference` CONVERT TO CHARACTER SET utf8mb4; + +ALTER TABLE `icingaweb_group` + MODIFY COLUMN `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL; +ALTER TABLE `icingaweb_group_membership` + MODIFY COLUMN `username` varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL; +ALTER TABLE `icingaweb_user` + MODIFY COLUMN `name` varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL; + +ALTER TABLE `icingaweb_user_preference` + MODIFY COLUMN `username` varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL, + MODIFY COLUMN `section` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, + MODIFY COLUMN `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL; diff --git a/etc/schema/mysql.schema.sql b/etc/schema/mysql.schema.sql index 62168c39d..18d9b2b83 100644 --- a/etc/schema/mysql.schema.sql +++ b/etc/schema/mysql.schema.sql @@ -2,7 +2,7 @@ CREATE TABLE `icingaweb_group`( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, `parent` int(10) unsigned NULL DEFAULT NULL, `ctime` timestamp NULL DEFAULT NULL, `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, @@ -10,36 +10,36 @@ CREATE TABLE `icingaweb_group`( UNIQUE KEY `idx_name` (`name`), CONSTRAINT `fk_icingaweb_group_parent_id` FOREIGN KEY (`parent`) REFERENCES `icingaweb_group` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `icingaweb_group_membership`( `group_id` int(10) unsigned NOT NULL, - `username` varchar(254) COLLATE utf8_unicode_ci NOT NULL, + `username` varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL, `ctime` timestamp NULL DEFAULT NULL, `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`group_id`,`username`), CONSTRAINT `fk_icingaweb_group_membership_icingaweb_group` FOREIGN KEY (`group_id`) REFERENCES `icingaweb_group` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `icingaweb_user`( - `name` varchar(254) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL, `active` tinyint(1) NOT NULL, `password_hash` varbinary(255) NOT NULL, `ctime` timestamp NULL DEFAULT NULL, `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `icingaweb_user_preference`( - `username` varchar(254) COLLATE utf8_unicode_ci NOT NULL, - `section` varchar(64) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `username` varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL, + `section` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, + `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, `value` varchar(255) NOT NULL, `ctime` timestamp NULL DEFAULT NULL, `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`username`,`section`,`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `icingaweb_rememberme`( id int(10) unsigned NOT NULL AUTO_INCREMENT, diff --git a/library/Icinga/Authentication/User/DbUserBackend.php b/library/Icinga/Authentication/User/DbUserBackend.php index 8b8062350..0e8cc6a54 100644 --- a/library/Icinga/Authentication/User/DbUserBackend.php +++ b/library/Icinga/Authentication/User/DbUserBackend.php @@ -21,7 +21,7 @@ class DbUserBackend extends DbRepository implements UserBackendInterface, Inspec */ protected $queryColumns = array( 'user' => array( - 'user' => 'name COLLATE utf8_general_ci', + 'user' => 'name COLLATE utf8mb4_general_ci', 'user_name' => 'name', 'is_active' => 'active', 'created_at' => 'UNIX_TIMESTAMP(ctime)', diff --git a/library/Icinga/Authentication/User/UserBackend.php b/library/Icinga/Authentication/User/UserBackend.php index 826c56e7d..f2059ed85 100644 --- a/library/Icinga/Authentication/User/UserBackend.php +++ b/library/Icinga/Authentication/User/UserBackend.php @@ -225,7 +225,7 @@ class UserBackend implements ConfigAwareFactory $resourceConfig = ResourceFactory::getResourceConfig($backendConfig->resource); if ($backendType === 'db' && $resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8'; + $resourceConfig->charset = 'utf8mb4'; } $resource = ResourceFactory::createResource($resourceConfig); diff --git a/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php index 04b556ade..66db97fdb 100644 --- a/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php @@ -22,7 +22,7 @@ class DbUserGroupBackend extends DbRepository implements Inspectable, UserGroupB protected $queryColumns = array( 'group' => array( 'group_id' => 'g.id', - 'group' => 'g.name COLLATE utf8_general_ci', + 'group' => 'g.name COLLATE utf8mb4_general_ci', 'group_name' => 'g.name', 'parent' => 'g.parent', 'created_at' => 'UNIX_TIMESTAMP(g.ctime)', @@ -30,7 +30,7 @@ class DbUserGroupBackend extends DbRepository implements Inspectable, UserGroupB ), 'group_membership' => array( 'group_id' => 'gm.group_id', - 'user' => 'gm.username COLLATE utf8_general_ci', + 'user' => 'gm.username COLLATE utf8mb4_general_ci', 'user_name' => 'gm.username', 'created_at' => 'UNIX_TIMESTAMP(gm.ctime)', 'last_modified' => 'UNIX_TIMESTAMP(gm.mtime)' diff --git a/library/Icinga/Authentication/UserGroup/UserGroupBackend.php b/library/Icinga/Authentication/UserGroup/UserGroupBackend.php index e73908739..76fa2d07e 100644 --- a/library/Icinga/Authentication/UserGroup/UserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/UserGroupBackend.php @@ -167,7 +167,7 @@ class UserGroupBackend $resourceConfig = ResourceFactory::getResourceConfig($backendConfig->resource); if ($backendType === 'db' && $resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8'; + $resourceConfig->charset = 'utf8mb4'; } $resource = ResourceFactory::createResource($resourceConfig); diff --git a/library/Icinga/User/Preferences/PreferencesStore.php b/library/Icinga/User/Preferences/PreferencesStore.php index a084314e4..d3c5f5397 100644 --- a/library/Icinga/User/Preferences/PreferencesStore.php +++ b/library/Icinga/User/Preferences/PreferencesStore.php @@ -132,7 +132,7 @@ abstract class PreferencesStore } elseif ($type === 'Db') { $resourceConfig = ResourceFactory::getResourceConfig($config->resource); if ($resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8'; + $resourceConfig->charset = 'utf8mb4'; } $config->connection = ResourceFactory::createResource($resourceConfig); diff --git a/modules/migrate/application/clicommands/PreferencesCommand.php b/modules/migrate/application/clicommands/PreferencesCommand.php index a8bfc76be..f31665493 100644 --- a/modules/migrate/application/clicommands/PreferencesCommand.php +++ b/modules/migrate/application/clicommands/PreferencesCommand.php @@ -38,7 +38,7 @@ class PreferencesCommand extends Command $resourceConfig = ResourceFactory::getResourceConfig($resource); if ($resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8'; + $resourceConfig->charset = 'utf8mb4'; } $connection = ResourceFactory::createResource($resourceConfig); diff --git a/modules/migrate/library/Migrate/Config/UserDomainMigration.php b/modules/migrate/library/Migrate/Config/UserDomainMigration.php index 480f74648..1c3f6e181 100644 --- a/modules/migrate/library/Migrate/Config/UserDomainMigration.php +++ b/modules/migrate/library/Migrate/Config/UserDomainMigration.php @@ -208,7 +208,7 @@ class UserDomainMigration case 'db': $resourceConfig = ResourceFactory::getResourceConfig($config->get('global', 'config_resource')); if ($resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8'; + $resourceConfig->charset = 'utf8mb4'; } /** @var DbConnection $conn */ @@ -295,7 +295,7 @@ class UserDomainMigration $resourceConfig = ResourceFactory::getResourceConfig($config->resource); if ($resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8'; + $resourceConfig->charset = 'utf8mb4'; } /** @var DbConnection $conn */ @@ -348,7 +348,7 @@ class UserDomainMigration $resourceConfig = ResourceFactory::getResourceConfig($config->resource); if ($resourceConfig->db === 'mysql') { - $resourceConfig->charset = 'utf8'; + $resourceConfig->charset = 'utf8mb4'; } /** @var DbConnection $conn */