Last active
March 29, 2019 12:08
-
-
Save arfaram/fd524e4b1887c77914143e80f39d1731 to your computer and use it in GitHub Desktop.
Upgrading your database from ezplatform 2.1 to 2.2. Below you'll find some sql queries to execute and a shell script to convert your table to use utf8mb4. More Information for the upgrade steps : https://doc.ezplatform.com/en/2.2/releases/updating_ez_platform/#4-update-database
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
-- | |
-- Avoid creating eznotification table again in enterprise edition, this table is already exist in 2.1. This could break the script and cause some key error when the script is executing once again | |
-- For Community edition see below "add_eznotification.sql" | |
-- | |
SET default_storage_engine=InnoDB; | |
BEGIN; | |
-- Set storage engine schema version number | |
UPDATE ezsite_data SET value='7.2.0' WHERE name='ezpublish-version'; | |
-- | |
-- EZP-28950: MySQL UTF8 doesn't support 4-byte chars | |
-- This shortens indexes so that 4-byte content can fit. | |
-- After running these, convert the table character set, see doc/upgrade/7.2.md | |
-- | |
ALTER TABLE `ezbasket` DROP KEY `ezbasket_session_id`; | |
ALTER TABLE `ezbasket` ADD KEY `ezbasket_session_id` (`session_id` (191)); | |
ALTER TABLE `ezcollab_group` DROP KEY `ezcollab_group_path`; | |
ALTER TABLE `ezcollab_group` ADD KEY `ezcollab_group_path` (`path_string` (191)); | |
ALTER TABLE `ezcontent_language` DROP KEY `ezcontent_language_name`; | |
ALTER TABLE `ezcontent_language` ADD KEY `ezcontent_language_name` (`name` (191)); | |
ALTER TABLE `ezcontentobject_attribute` DROP KEY `sort_key_string`; | |
ALTER TABLE `ezcontentobject_attribute` ADD KEY `sort_key_string` (`sort_key_string` (191)); | |
ALTER TABLE `ezcontentobject_name` DROP KEY `ezcontentobject_name_name`; | |
ALTER TABLE `ezcontentobject_name` ADD KEY `ezcontentobject_name_name` (`name` (191)); | |
ALTER TABLE `ezcontentobject_trash` DROP KEY `ezcobj_trash_path`; | |
ALTER TABLE `ezcontentobject_trash` ADD KEY `ezcobj_trash_path` (`path_string` (191)); | |
ALTER TABLE `ezcontentobject_tree` DROP KEY `ezcontentobject_tree_path`; | |
ALTER TABLE `ezcontentobject_tree` ADD KEY `ezcontentobject_tree_path` (`path_string` (191)); | |
ALTER TABLE `ezimagefile` DROP KEY `ezimagefile_file`; | |
ALTER TABLE `ezimagefile` ADD KEY `ezimagefile_file` (`filepath` (191)); | |
ALTER TABLE `ezkeyword` DROP KEY `ezkeyword_keyword`; | |
ALTER TABLE `ezkeyword` ADD KEY `ezkeyword_keyword` (`keyword` (191)); | |
ALTER TABLE `ezorder_status` DROP KEY `ezorder_status_name`; | |
ALTER TABLE `ezorder_status` ADD KEY `ezorder_status_name` (`name` (191)); | |
ALTER TABLE `ezpolicy_limitation_value` DROP KEY `ezpolicy_limitation_value_val`; | |
ALTER TABLE `ezpolicy_limitation_value` ADD KEY `ezpolicy_limitation_value_val` (`value` (191)); | |
ALTER TABLE `ezprest_authcode` DROP PRIMARY KEY; | |
ALTER TABLE `ezprest_authcode` ADD PRIMARY KEY (`id` (191)); | |
ALTER TABLE `ezprest_authcode` DROP KEY `authcode_client_id`; | |
ALTER TABLE `ezprest_authcode` ADD KEY `authcode_client_id` (`client_id` (191)); | |
ALTER TABLE `ezprest_clients` DROP KEY `client_id_unique`; | |
ALTER TABLE `ezprest_clients` ADD UNIQUE KEY `client_id_unique` (`client_id` (191),`version`); | |
ALTER TABLE `ezprest_token` DROP PRIMARY KEY; | |
ALTER TABLE `ezprest_token` ADD PRIMARY KEY (`id` (191)); | |
ALTER TABLE `ezprest_token` DROP KEY `token_client_id`; | |
ALTER TABLE `ezprest_token` ADD KEY `token_client_id` (`client_id` (191)); | |
ALTER TABLE `ezsearch_object_word_link` DROP KEY `ezsearch_object_word_link_identifier`; | |
ALTER TABLE `ezsearch_object_word_link` ADD KEY `ezsearch_object_word_link_identifier` (`identifier` (191)); | |
ALTER TABLE `ezsearch_search_phrase` DROP KEY `ezsearch_search_phrase_phrase`; | |
ALTER TABLE `ezsearch_search_phrase` ADD UNIQUE KEY `ezsearch_search_phrase_phrase` (`phrase` (191)); | |
ALTER TABLE `ezurl` DROP KEY `ezurl_url`; | |
ALTER TABLE `ezurl` ADD KEY `ezurl_url` (`url` (191)); | |
ALTER TABLE `ezurlalias` DROP KEY `ezurlalias_desturl`; | |
ALTER TABLE `ezurlalias` ADD KEY `ezurlalias_desturl` (`destination_url` (191)); | |
ALTER TABLE `ezurlalias` DROP KEY `ezurlalias_source_url`; | |
ALTER TABLE `ezurlalias` ADD KEY `ezurlalias_source_url` (`source_url` (191)); | |
-- | |
-- EZP-29146: As a developer, I want a API to manage bookmarks | |
-- | |
ALTER TABLE `ezcontentbrowsebookmark` | |
ADD INDEX `ezcontentbrowsebookmark_user_location` (`node_id`, `user_id`); | |
ALTER TABLE `ezcontentbrowsebookmark` | |
ADD INDEX `ezcontentbrowsebookmark_location` (`node_id`); | |
ALTER TABLE `ezcontentbrowsebookmark` | |
ADD CONSTRAINT `ezcontentbrowsebookmark_location_fk` | |
FOREIGN KEY (`node_id`) | |
REFERENCES `ezcontentobject_tree` (`node_id`) | |
ON DELETE CASCADE | |
ON UPDATE NO ACTION; | |
ALTER TABLE `ezcontentbrowsebookmark` | |
ADD CONSTRAINT `ezcontentbrowsebookmark_user_fk` | |
FOREIGN KEY (`user_id`) | |
REFERENCES `ezuser` (`contentobject_id`) | |
ON DELETE CASCADE | |
ON UPDATE NO ACTION; | |
COMMIT; | |
-- If the queries below fail, it means database is already updated | |
CREATE INDEX `ezcontentobject_tree_contentobject_id_path_string` ON `ezcontentobject_tree` (`path_string`, `contentobject_id`); | |
CREATE INDEX `ezcontentobject_section` ON `ezcontentobject` (`section_id`); |
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
-- | |
-- EZEE-2081: Move NotificationBundle into AdminUI. | |
-- Only for open source version upgrade | |
-- | |
CREATE TABLE `eznotification` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`owner_id` int(11) NOT NULL DEFAULT 0, | |
`is_pending` tinyint(1) NOT NULL DEFAULT '1', | |
`type` varchar(128) NOT NULL DEFAULT '', | |
`created` int(11) NOT NULL DEFAULT 0, | |
`data` blob, | |
PRIMARY KEY (`id`), | |
KEY `eznotification_owner` (`owner_id`), | |
KEY `eznotification_owner_is_pending` (`owner_id`, `is_pending`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
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
-- Replace with your database name | |
ALTER DATABASE <DATABASE_NAME> CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; |
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
In app/config/config.yml, set the following: | |
doctrine: | |
dbal: | |
connections: | |
default: | |
charset: utf8mb4 | |
Also make the corresponding change in app/config/dfs/dfs.yml. |
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
#!/bin/bash | |
# Input data | |
USER="USERNAME" | |
PASSWORD="PASSWORD" | |
DB_NAME="DATABASE_NAME" | |
# END of Input data | |
CHARACTER_SET="utf8mb4" # your default character set | |
COLLATE="utf8mb4_general_ci" # your default collation | |
tables=`mysql -u $USER -p$PASSWORD -e "SELECT tbl.TABLE_NAME FROM information_schema.TABLES tbl WHERE tbl.TABLE_SCHEMA = '$DB_NAME' AND tbl.TABLE_TYPE='BASE TABLE'"` | |
for tableName in $tables; do | |
if [[ "$tableName" != "TABLE_NAME" ]] ; then | |
mysql -u $USER -p$PASSWORD -e "ALTER TABLE $DB_NAME.$tableName DEFAULT CHARACTER SET $CHARACTER_SET COLLATE $COLLATE;" | |
echo "$tableName - done" | |
fi | |
done |
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
-- | |
-- Page Builder | |
-- | |
DROP TABLE IF EXISTS `ezpage_attributes`; | |
CREATE TABLE `ezpage_attributes` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(255) NOT NULL DEFAULT '', | |
`value` text, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_blocks`; | |
CREATE TABLE `ezpage_blocks` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`type` varchar(255) NOT NULL DEFAULT '', | |
`view` varchar(255) NOT NULL DEFAULT '', | |
`name` varchar(255) NOT NULL DEFAULT '', | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_blocks_design`; | |
CREATE TABLE `ezpage_blocks_design` ( | |
`id` INT(11) NOT NULL AUTO_INCREMENT, | |
`block_id` INT(11) NOT NULL, | |
`style` TEXT DEFAULT NULL, | |
`compiled` TEXT DEFAULT NULL, | |
`class` VARCHAR(255) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_blocks_visibility`; | |
CREATE TABLE `ezpage_blocks_visibility` ( | |
`id` INT(11) NOT NULL AUTO_INCREMENT, | |
`block_id` INT(11) NOT NULL, | |
`since` INT(11) DEFAULT NULL, | |
`till` INT(11) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_map_attributes_blocks`; | |
CREATE TABLE `ezpage_map_attributes_blocks` ( | |
`attribute_id` int(11) NOT NULL, | |
`block_id` int(11) NOT NULL, | |
PRIMARY KEY (`attribute_id`,`block_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_map_blocks_zones`; | |
CREATE TABLE `ezpage_map_blocks_zones` ( | |
`block_id` int(11) NOT NULL, | |
`zone_id` int(11) NOT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_map_zones_pages`; | |
CREATE TABLE `ezpage_map_zones_pages` ( | |
`zone_id` int(11) NOT NULL, | |
`page_id` int(11) NOT NULL, | |
PRIMARY KEY (`zone_id`,`page_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_pages`; | |
CREATE TABLE `ezpage_pages` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`version_no` int(11) unsigned NOT NULL, | |
`content_id` int(11) NOT NULL, | |
`language_code` varchar(255) NOT NULL DEFAULT '', | |
`layout` varchar(255) NOT NULL DEFAULT '', | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |
DROP TABLE IF EXISTS `ezpage_zones`; | |
CREATE TABLE `ezpage_zones` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(255) NOT NULL DEFAULT '', | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, the page builder sql,
ezpage_map_blocks_zones
table doesn't have the primary key or an index on the block_id.I'm not sure if the other way is also necessary but we at least know that without that one, a site can get offline under high load.
One solution is adding the primary key to the table
or if the index on the other way is also needed for some other possible query