-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #689 from M0rgan01/fix/sql
Update missing SQL compare to a fresh install
- Loading branch information
Showing
10 changed files
with
140 additions
and
10 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
upgrade/php/add_missing_unique_key_from_authorization_role.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@prestashop.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
// Allows you to catch up on a forgotten uniqueness constraint on the roles | ||
function add_missing_unique_key_from_authorization_role() | ||
{ | ||
// Verify if we need to create unique key | ||
$keys = Db::getInstance()->executeS( | ||
'SHOW KEYS FROM ' . _DB_PREFIX_ . "authorization_role WHERE Key_name='slug'" | ||
); | ||
|
||
if (!empty($keys)) { | ||
return; | ||
} | ||
|
||
// We recover the duplicates that we want to keep | ||
$duplicates = Db::getInstance()->executeS( | ||
'SELECT MIN(id_authorization_role) AS keep_ID, slug FROM ' . _DB_PREFIX_ . 'authorization_role GROUP BY slug HAVING COUNT(*) > 1' | ||
); | ||
|
||
if (empty($duplicates)) { | ||
return; | ||
} | ||
|
||
foreach ($duplicates as $duplicate) { | ||
// We recover the duplicates that we want to remove | ||
$elementsToRemoves = Db::getInstance()->executeS( | ||
'SELECT id_authorization_role FROM ' . _DB_PREFIX_ . "authorization_role WHERE slug = '" . $duplicate['slug'] . "' AND id_authorization_role != " . $duplicate['keep_ID'] | ||
); | ||
|
||
foreach ($elementsToRemoves as $elementToRemove) { | ||
// We update the access table which may have used a duplicate role | ||
Db::getInstance()->execute( | ||
'UPDATE ' . _DB_PREFIX_ . "access SET id_authorization_role = '" . $duplicate['keep_ID'] . "' WHERE id_authorization_role = " . $elementToRemove['id_authorization_role'] | ||
); | ||
// We remove the role | ||
Db::getInstance()->delete('authorization_role', '`id_authorization_role` = ' . (int) $elementToRemove['id_authorization_role']); | ||
} | ||
} | ||
|
||
Db::getInstance()->execute( | ||
'ALTER TABLE ' . _DB_PREFIX_ . 'authorization_role ADD UNIQUE KEY `slug` (`slug`)' | ||
); | ||
} |
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* script intended for catching up with requests forgotten since 1.7 */ | ||
|
||
/* 1.7.1.0 */ | ||
ALTER TABLE `PREFIX_product` CHANGE `id_type_redirected` `id_type_redirected` INT(10) UNSIGNED NOT NULL DEFAULT '0'; | ||
ALTER TABLE `PREFIX_product_shop` CHANGE `id_type_redirected` `id_type_redirected` INT(10) UNSIGNED NOT NULL DEFAULT '0'; | ||
|
||
ALTER TABLE `PREFIX_tab` CHANGE `active` `active` TINYINT(1) NOT NULL; | ||
ALTER TABLE `PREFIX_tab` CHANGE `icon` `icon` VARCHAR(32) DEFAULT NULL; | ||
|
||
/* PHP:add_missing_unique_key_from_authorization_role(); */; | ||
|
||
/* 1.7.2.0 */ | ||
ALTER TABLE `PREFIX_stock_mvt` CHANGE `sign` `sign` SMALLINT(6) NOT NULL DEFAULT '1'; | ||
ALTER TABLE `PREFIX_carrier_lang` CHANGE `delay` `delay` VARCHAR(512) DEFAULT NULL; | ||
|
||
/* 1.7.5.0 */ | ||
ALTER TABLE `PREFIX_manufacturer_lang` CHANGE `meta_title` `meta_title` VARCHAR(255) DEFAULT NULL; | ||
UPDATE `PREFIX_stock` SET `reference` = '' WHERE `reference` IS NULL; | ||
ALTER TABLE `PREFIX_stock` CHANGE `reference` `reference` VARCHAR(64) NOT NULL; | ||
|
||
/* 1.7.6.0 */ | ||
ALTER TABLE `PREFIX_currency` CHANGE `numeric_iso_code` `numeric_iso_code` VARCHAR(3) DEFAULT NULL AFTER `iso_code`; | ||
|
||
/* 1.7.8.0 */ | ||
DROP TABLE IF EXISTS `PREFIX_order_slip_detail_tax`; | ||
|
||
/* 8.0.0 */ | ||
DROP TABLE IF EXISTS `PREFIX_attribute_impact`; | ||
/* PHP:drop_column_if_exists('orders', 'shipping_number'); */; |
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