Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SQL commands related to doctrine and remove Doctrine usage #636

Merged
merged 16 commits into from
May 22, 2024
10 changes: 0 additions & 10 deletions classes/UpgradeTools/CoreUpgrader/CoreUpgrader17.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ protected function initConstants()
$this->container->getSymfonyAdapter()->initKernel();
}

protected function upgradeDb($oldversion)
{
parent::upgradeDb($oldversion);

$commandResult = $this->container->getSymfonyAdapter()->runSchemaUpgradeCommand();
if (0 !== $commandResult['exitCode']) {
throw (new UpgradeException($this->container->getTranslator()->trans('Error upgrading Doctrine schema', [], 'Modules.Autoupgrade.Admin')))->setQuickInfos(explode("\n", $commandResult['output']));
}
}

protected function upgradeLanguage($lang)
{
$isoCode = $lang['iso_code'];
Expand Down
10 changes: 0 additions & 10 deletions classes/UpgradeTools/CoreUpgrader/CoreUpgrader80.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ protected function forceRemovingFiles()
}
}

protected function upgradeDb($oldversion)
{
parent::upgradeDb($oldversion);

$commandResult = $this->container->getSymfonyAdapter()->runSchemaUpgradeCommand();
if (0 !== $commandResult['exitCode']) {
throw (new UpgradeException($this->container->getTranslator()->trans('Error upgrading Doctrine schema', [], 'Modules.Autoupgrade.Admin')))->setQuickInfos(explode("\n", $commandResult['output']));
}
}

protected function upgradeLanguage($lang)
{
$isoCode = $lang['iso_code'];
Expand Down
16 changes: 0 additions & 16 deletions classes/UpgradeTools/SymfonyAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@ public function __construct($destinationPsVersion)
$this->destinationPsVersion = $destinationPsVersion;
}

public function runSchemaUpgradeCommand()
{
if (version_compare($this->destinationPsVersion, '1.7.1.1', '>=')) {
$schemaUpgrade = new \PrestaShopBundle\Service\Database\Upgrade();
$outputCommand = 'prestashop:schema:update-without-foreign';
} else {
$schemaUpgrade = new \PrestaShopBundle\Service\Cache\Refresh();
$outputCommand = 'doctrine:schema:update';
}

$schemaUpgrade->addDoctrineSchemaUpdate();
$output = $schemaUpgrade->execute();

return $output[$outputCommand];
}

/**
* Return the appropriate kernel if abstract or not.
*
Expand Down
16 changes: 15 additions & 1 deletion upgrade/sql/1.7.1.1.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
SET NAMES 'utf8';

ALTER TABLE `PREFIX_address` CHANGE `company` `company` VARCHAR(255) DEFAULT NULL;
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;
9 changes: 8 additions & 1 deletion upgrade/sql/1.7.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ ALTER TABLE `PREFIX_supply_order_detail` CHANGE `isbn` `isbn` VARCHAR(32) NULL D

ALTER TABLE `PREFIX_stock_available` ADD `physical_quantity` INT NOT NULL DEFAULT '0' AFTER `quantity`;
ALTER TABLE `PREFIX_stock_available` ADD `reserved_quantity` INT NOT NULL DEFAULT '0' AFTER `physical_quantity`;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_stock` `id_stock` INT(11) UNSIGNED NOT NULL COMMENT 'since ps 1.7 corresponding to id_stock_available';
ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_stock` `id_stock` INT(11) NOT NULL COMMENT 'since ps 1.7 corresponding to id_stock_available';
ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_stock_mvt` `id_stock_mvt` BIGINT(20) NOT NULL AUTO_INCREMENT;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_order` `id_order` INT(11) DEFAULT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_supply_order` `id_supply_order` INT(11) DEFAULT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_stock_mvt_reason` `id_stock_mvt_reason` INT(11) NOT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `id_employee` `id_employee` INT(11) NOT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `physical_quantity` `physical_quantity` INT(11) NOT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `referer` `referer` BIGINT(20) DEFAULT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `employee_lastname` `employee_lastname` varchar(32) DEFAULT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `employee_firstname` `employee_firstname` varchar(32) DEFAULT NULL;
ALTER TABLE `PREFIX_stock_mvt` CHANGE `sign` `sign` smallint(6) NOT NULL DEFAULT '1';
Expand Down
9 changes: 9 additions & 0 deletions upgrade/sql/1.7.5.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ ALTER TABLE `PREFIX_product_lang`

ALTER TABLE `PREFIX_customer_thread`
CHANGE `email` `email` varchar(255) NOT NULL;

ALTER TABLE `PREFIX_attribute_group_lang`
ADD KEY `IDX_4653726CBA299860` (`id_lang`);

ALTER TABLE `PREFIX_attribute_lang`
ADD KEY `IDX_3ABE46A7BA299860` (`id_lang`);

ALTER TABLE `PREFIX_tab_lang`
ADD KEY `IDX_CFD9262DBA299860` (`id_lang`);
6 changes: 6 additions & 0 deletions upgrade/sql/1.7.6.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,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`;
5 changes: 5 additions & 0 deletions upgrade/sql/1.7.7.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ ALTER TABLE `PREFIX_product_download` CHANGE `display_filename` `display_filenam

/* 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 route_name VARCHAR(256) DEFAULT NULL;
ALTER TABLE `PREFIX_tab` CHANGE class_name class_name VARCHAR(64) NOT NULL;

/* PHP:ps_1770_preset_tab_enabled(); */;
/* PHP:ps_1770_update_order_status_colors(); */;
Expand Down Expand Up @@ -678,3 +680,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;
9 changes: 9 additions & 0 deletions upgrade/sql/1.7.8.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,12 @@ 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;
ALTER TABLE `PREFIX_shop_url` CHANGE id_shop id_shop INT NOT NULL;
CREATE INDEX IDX_279F19DA274A50A0 ON `PREFIX_shop_url` (id_shop);
Quetzacoalt91 marked this conversation as resolved.
Show resolved Hide resolved
ALTER TABLE `PREFIX_shop` ADD color VARCHAR(50) NOT NULL;
ALTER TABLE `PREFIX_shop_group` ADD color VARCHAR(50) NOT NULL;
4 changes: 4 additions & 0 deletions upgrade/sql/8.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,7 @@ UPDATE `PREFIX_carrier` SET `name` = 'Click and collect' WHERE `name` = '0';
/* PHP:drop_column_if_exists('product_attribute', 'location'); */;
/* PHP:drop_column_if_exists('product_attribute', 'quantity'); */;
/* PHP:drop_column_if_exists('orders', 'shipping_number'); */;

ALTER TABLE `PREFIX_tab` DROP hide_host_mode;
ALTER TABLE `PREFIX_feature_flag` CHANGE label_wording label_wording VARCHAR(512) DEFAULT '' NOT NULL;
ALTER TABLE `PREFIX_feature_flag` CHANGE description_wording description_wording VARCHAR(512) DEFAULT '' NOT NULL;
21 changes: 21 additions & 0 deletions upgrade/sql/8.1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,24 @@ 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)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
40 changes: 40 additions & 0 deletions upgrade/sql/9.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,43 @@ DROP TABLE `PREFIX_accessory`;
RENAME TABLE `PREFIX_accessory_tmp` TO `PREFIX_accessory`;

ALTER TABLE `PREFIX_stock_mvt` MODIFY `id_supply_order` INT(11) DEFAULT '0';

DROP TABLE IF EXISTS `PREFIX_api_access`;
DROP TABLE IF EXISTS `PREFIX_authorized_application`;
CREATE TABLE `PREFIX_api_client`
(
`id_api_client` int(10) unsigned NOT NULL AUTO_INCREMENT,
`client_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`client_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`client_secret` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`enabled` tinyint(1) NOT NULL,
`scopes` json NOT NULL,
`description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`external_issuer` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`lifetime` int(11) NOT NULL DEFAULT '3600',
PRIMARY KEY (`id_api_client`),
UNIQUE KEY `api_client_client_id_idx` (`client_id`,`external_issuer`),
UNIQUE KEY `api_client_client_name_idx` (`client_name`,`external_issuer`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `PREFIX_image_type`
CHANGE `id_image_type` `id_image_type` int(11) NOT NULL AUTO_INCREMENT,
CHANGE `width` `width` int(11) NOT NULL,
CHANGE `height` `height` int(11) NOT NULL,
CHANGE `products` `products` tinyint(1) NOT NULL,
CHANGE `manufacturers` `manufacturers` tinyint(1) NOT NULL,
CHANGE `stores` `stores` tinyint(1) NOT NULL,
DROP key `image_type_name`,
ADD UNIQUE KEY `UNIQ_907C95215E237E06` (`name`);

CREATE TABLE `PREFIX_mutation` (
`id_mutation` int(10) unsigned NOT NULL AUTO_INCREMENT,
`mutation_table` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`mutation_row_id` bigint(20) NOT NULL,
`mutation_action` enum('create','update','delete') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`mutator_type` enum('employee','api_client','module') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`mutator_identifier` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`mutation_details` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`date_add` datetime NOT NULL,
PRIMARY KEY (`id_mutation`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;