From 6732dd26d9b0ea563f1bfbf540733ceb6abf92a0 Mon Sep 17 00:00:00 2001 From: Morgan Pichat Date: Mon, 25 Sep 2023 16:48:01 +0200 Subject: [PATCH] Add doctrine SQL migration --- upgrade/sql/1.7.1.1.sql | 16 +++++++++++++++- upgrade/sql/1.7.2.0.sql | 13 +++++++++++++ upgrade/sql/1.7.5.0.sql | 4 ++++ upgrade/sql/1.7.6.0.sql | 6 ++++++ upgrade/sql/1.7.7.0.sql | 7 ++++--- upgrade/sql/1.7.8.0.sql | 8 ++++++++ upgrade/sql/8.0.0.sql | 7 +++++-- upgrade/sql/8.1.0.sql | 27 +++++++++++++++++++++++++++ upgrade/sql/8.1.1.sql | 2 ++ 9 files changed, 84 insertions(+), 6 deletions(-) diff --git a/upgrade/sql/1.7.1.1.sql b/upgrade/sql/1.7.1.1.sql index a0c5e9992e..d627fbee7f 100644 --- a/upgrade/sql/1.7.1.1.sql +++ b/upgrade/sql/1.7.1.1.sql @@ -1,3 +1,17 @@ SET NAMES 'utf8'; -ALTER TABLE `PREFIX_address` CHANGE `company` `company` VARCHAR(255) DEFAULT NULL; \ No newline at end of file +ALTER TABLE `PREFIX_address` CHANGE `company` `company` VARCHAR(255) DEFAULT NULL; + +ALTER TABLE `PREFIX_attribute` DROP FOREIGN KEY FK_6C3355F967A664FB; +ALTER TABLE `PREFIX_attribute_group_lang` DROP FOREIGN KEY FK_4653726C67A664FB; +ALTER TABLE `PREFIX_attribute_group_shop` DROP FOREIGN KEY FK_DB30BAAC274A50A0; +ALTER TABLE `PREFIX_attribute_group_shop` DROP FOREIGN KEY FK_DB30BAAC67A664FB; +ALTER TABLE `PREFIX_attribute_lang` DROP FOREIGN KEY FK_3ABE46A77A4F53DC; +ALTER TABLE `PREFIX_attribute_shop` DROP FOREIGN KEY FK_A7DD8E67274A50A0; +ALTER TABLE `PREFIX_attribute_shop` DROP FOREIGN KEY FK_A7DD8E677A4F53DC; +ALTER TABLE `PREFIX_lang_shop` DROP FOREIGN KEY FK_2F43BFC7274A50A0; +ALTER TABLE `PREFIX_lang_shop` DROP FOREIGN KEY FK_2F43BFC7BA299860; +ALTER TABLE `PREFIX_shop` DROP FOREIGN KEY FK_CBDFBB9EF5C9E40; +ALTER TABLE `PREFIX_tab_lang` DROP FOREIGN KEY FK_CFD9262DED47AB56; +ALTER TABLE `PREFIX_translation` DROP FOREIGN KEY FK_ADEBEB36BA299860; +ALTER TABLE `PREFIX_tab` CHANGE icon icon VARCHAR(32) DEFAULT NULL; diff --git a/upgrade/sql/1.7.2.0.sql b/upgrade/sql/1.7.2.0.sql index a8fe77e7cc..063fe69fce 100644 --- a/upgrade/sql/1.7.2.0.sql +++ b/upgrade/sql/1.7.2.0.sql @@ -33,3 +33,16 @@ ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_stock` `id_stock` INT(11) UNSIGNED NOT UPDATE `PREFIX_configuration` SET `value` = 0 WHERE `name` = "PS_ADVANCED_STOCK_MANAGEMENT"; /* PHP:add_new_status_stock(); */; + +ALTER TABLE `PREFIX_stock_mvt` + CHANGE id_stock_mvt id_stock_mvt BIGINT AUTO_INCREMENT NOT NULL, + CHANGE id_stock id_stock INT NOT NULL, + CHANGE id_order id_order INT DEFAULT NULL, + CHANGE id_supply_order id_supply_order INT DEFAULT NULL, + CHANGE id_stock_mvt_reason id_stock_mvt_reason INT NOT NULL, + CHANGE id_employee id_employee INT NOT NULL, + CHANGE employee_lastname employee_lastname VARCHAR(32) DEFAULT '', + CHANGE employee_firstname employee_firstname VARCHAR(32) DEFAULT '', + CHANGE physical_quantity physical_quantity INT NOT NULL, + CHANGE sign sign SMALLINT DEFAULT '1', + CHANGE referer referer BIGINT DEFAULT NULL; diff --git a/upgrade/sql/1.7.5.0.sql b/upgrade/sql/1.7.5.0.sql index 572e938d25..d3c5360587 100644 --- a/upgrade/sql/1.7.5.0.sql +++ b/upgrade/sql/1.7.5.0.sql @@ -88,3 +88,7 @@ ALTER TABLE `PREFIX_product_lang` ALTER TABLE `PREFIX_customer_thread` CHANGE `email` `email` varchar(255) NOT NULL; + +CREATE INDEX IDX_3ABE46A7BA299860 ON `PREFIX_attribute_lang` (id_lang); +CREATE INDEX IDX_4653726CBA299860 ON `PREFIX_attribute_group_lang` (id_lang); +CREATE INDEX IDX_CFD9262DBA299860 ON `PREFIX_tab_lang` (id_lang); diff --git a/upgrade/sql/1.7.6.0.sql b/upgrade/sql/1.7.6.0.sql index 7d2bb7dd1a..7f37bef1bd 100644 --- a/upgrade/sql/1.7.6.0.sql +++ b/upgrade/sql/1.7.6.0.sql @@ -270,3 +270,9 @@ INSERT IGNORE INTO `PREFIX_authorization_role` (`slug`) VALUES ('ROLE_MOD_TAB_ADMINPARENTMODULESCATALOG_READ'), ('ROLE_MOD_TAB_ADMINPARENTMODULESCATALOG_UPDATE'), ('ROLE_MOD_TAB_ADMINPARENTMODULESCATALOG_DELETE'); + +DROP INDEX admin_filter_search_idx ON `PREFIX_admin_filter`; +ALTER TABLE `PREFIX_admin_filter` ADD filter_id VARCHAR(255) NOT NULL; +CREATE UNIQUE INDEX admin_filter_search_id_idx ON `PREFIX_admin_filter` (employee, shop, controller, action, filter_id); +DROP INDEX id_product ON `PREFIX_product_download`; +DROP INDEX product_active ON `PREFIX_product_download`; diff --git a/upgrade/sql/1.7.7.0.sql b/upgrade/sql/1.7.7.0.sql index 65626588d2..2f41fa6e13 100644 --- a/upgrade/sql/1.7.7.0.sql +++ b/upgrade/sql/1.7.7.0.sql @@ -310,9 +310,7 @@ ALTER TABLE `PREFIX_stock` CHANGE `upc` `upc` varchar(12) CHARACTER SET utf8mb4 ALTER TABLE `PREFIX_attribute_lang` CHANGE `name` `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL; ALTER TABLE `PREFIX_connections` CHANGE `http_referer` `http_referer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL; ALTER TABLE `PREFIX_product_download` CHANGE `display_filename` `display_filename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL; - -/* Doctrine update happens too late to update the new enabled field, so we preset everything here */ -ALTER TABLE `PREFIX_tab` ADD enabled TINYINT(1) NOT NULL; +ALTER TABLE `PREFIX_tab` ADD enabled TINYINT(1) NOT NULL, ADD route_name VARCHAR(256) DEFAULT NULL, CHANGE class_name class_name VARCHAR(64) NOT NULL; /* PHP:ps_1770_preset_tab_enabled(); */; /* PHP:ps_1770_update_order_status_colors(); */; @@ -678,3 +676,6 @@ DELETE FROM `PREFIX_hook` WHERE name = 'actionFrontControllerAfterInit'; /* Update wrong hook alias */ UPDATE `PREFIX_hook_alias` SET name = 'displayHeader', alias = 'Header' WHERE name = 'Header' AND alias = 'displayHeader'; + +ALTER TABLE `PREFIX_translation` CHANGE `key` `key` TEXT NOT NULL COLLATE utf8_bin; +ALTER TABLE `PREFIX_admin_filter` CHANGE filter_id filter_id VARCHAR(191) NOT NULL; diff --git a/upgrade/sql/1.7.8.0.sql b/upgrade/sql/1.7.8.0.sql index 989c96ff81..c6879b983e 100644 --- a/upgrade/sql/1.7.8.0.sql +++ b/upgrade/sql/1.7.8.0.sql @@ -199,3 +199,11 @@ CREATE TABLE IF NOT EXISTS `PREFIX_feature_flag` ( INSERT INTO `PREFIX_feature_flag` (`name`, `state`, `label_wording`, `label_domain`, `description_wording`, `description_domain`) VALUES ('product_page_v2', 0, 'Experimental product page', 'Admin.Advparameters.Feature', 'This page benefits from increased performance and includes new features such as a new combination management system. Please note this is a work in progress and some features are not available yet.', 'Admin.Advparameters.Help'); + +DROP INDEX id_shop ON `PREFIX_shop_url`; +DROP INDEX full_shop_url ON `PREFIX_shop_url`; +DROP INDEX full_shop_url_ssl ON `PREFIX_shop_url`; +ALTER TABLE `PREFIX_shop_url` CHANGE id_shop_url id_shop_url INT AUTO_INCREMENT NOT NULL, CHANGE id_shop id_shop INT NOT NULL; +CREATE INDEX IDX_279F19DA274A50A0 ON `PREFIX_shop_url` (id_shop); +ALTER TABLE `PREFIX_shop` ADD color VARCHAR(50) NOT NULL; +ALTER TABLE `PREFIX_shop_group` ADD color VARCHAR(50) NOT NULL; diff --git a/upgrade/sql/8.0.0.sql b/upgrade/sql/8.0.0.sql index d01877d599..b627701657 100644 --- a/upgrade/sql/8.0.0.sql +++ b/upgrade/sql/8.0.0.sql @@ -192,8 +192,6 @@ ALTER TABLE `PREFIX_product_shop` MODIFY COLUMN `redirect_type` ENUM( '404', '410', '301-product', '302-product', '301-category', '302-category' ) NOT NULL DEFAULT '404'; -ALTER TABLE `PREFIX_tab` ADD route_name VARCHAR(256) DEFAULT NULL; - /* PHP:ps_800_add_security_tab(); */; ALTER TABLE `PREFIX_order_detail` MODIFY COLUMN `product_name` TEXT NOT NULL; @@ -235,3 +233,8 @@ UPDATE `PREFIX_carrier` SET `name` = 'Click and collect' WHERE `name` = '0'; /* Remove deprecated columns */ /* PHP:drop_column_if_exists('product_attribute', 'location'); */; /* PHP:drop_column_if_exists('product_attribute', 'quantity'); */; + +ALTER TABLE `PREFIX_tab` DROP hide_host_mode; +ALTER TABLE `PREFIX_feature_flag` + CHANGE label_wording label_wording VARCHAR(512) DEFAULT '' NOT NULL, + CHANGE description_wording description_wording VARCHAR(512) DEFAULT '' NOT NULL; diff --git a/upgrade/sql/8.1.0.sql b/upgrade/sql/8.1.0.sql index 7220b13b57..642e342e95 100644 --- a/upgrade/sql/8.1.0.sql +++ b/upgrade/sql/8.1.0.sql @@ -70,3 +70,30 @@ ALTER TABLE `PREFIX_stock_mvt` CHANGE `physical_quantity` `physical_quantity` IN /* PHP:add_hook('actionAdminBreadcrumbModifier', 'Modify back office breadcrumb', 'This hook allows modifying back office breadcrumb'); */; ALTER TABLE `PREFIX_order_payment` ADD `id_employee` INT NULL AFTER `date_add`; + +CREATE TABLE `PREFIX_authorized_application` +( + id_authorized_application INT UNSIGNED AUTO_INCREMENT NOT NULL, + name VARCHAR(255) NOT NULL, + description LONGTEXT NOT NULL, + UNIQUE INDEX UNIQ_475B9BA55E237E06 (name), + PRIMARY KEY (id_authorized_application) +) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB; + +CREATE TABLE `PREFIX_api_access` +( + id_api_access INT UNSIGNED AUTO_INCREMENT NOT NULL, + id_authorized_application INT UNSIGNED NOT NULL, + client_id VARCHAR(255) NOT NULL, + client_secret VARCHAR(255) NOT NULL, + active TINYINT(1) NOT NULL, + scopes LONGTEXT NOT NULL COMMENT '(DC2Type:array)', + INDEX IDX_6E064442D8BFF738 (id_authorized_application), + PRIMARY KEY (id_api_access) +) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB; + +ALTER TABLE `PREFIX_stock_mvt` + CHANGE employee_lastname employee_lastname VARCHAR (255) DEFAULT NULL, + CHANGE employee_firstname employee_firstname VARCHAR (255) DEFAULT NULL, + CHANGE physical_quantity physical_quantity INT UNSIGNED NOT NULL; + diff --git a/upgrade/sql/8.1.1.sql b/upgrade/sql/8.1.1.sql index dee82b91bd..494ca72390 100644 --- a/upgrade/sql/8.1.1.sql +++ b/upgrade/sql/8.1.1.sql @@ -3,3 +3,5 @@ SET NAMES 'utf8mb4'; /* We forgot to update redirect_type in 8.1.0. This updates it, if it's not done already */ /* PHP:ps_811_update_redirect_type(); */; + +ALTER TABLE `PREFIX_authorized_application` CHANGE name name VARCHAR(50) NOT NULL;