diff --git a/install-dev/php/update_tax_rules.php b/install-dev/php/update_tax_rules.php deleted file mode 100644 index 252c4dd60..000000000 --- a/install-dev/php/update_tax_rules.php +++ /dev/null @@ -1,48 +0,0 @@ -Execute(' - ALTER TABLE `'._DB_PREFIX_.'tax_rule` - ADD `zipcode_from` INT NOT NULL AFTER `id_state` , - ADD `zipcode_to` INT NOT NULL AFTER `zipcode_from` , - ADD `behavior` INT NOT NULL AFTER `zipcode_to`, - ADD `description` VARCHAR( 100 ) NOT NULL AFTER `id_tax`; - '); - - // Drop integrity constraint - Db::getInstance()->Execute(' - ALTER TABLE `'._DB_PREFIX_.'tax_rule` DROP INDEX tax_rule - '); - - // Create new format rules - Db::getInstance()->Execute(' - INSERT INTO `'._DB_PREFIX_.'tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `id_tax`, `behavior`, `zipcode_from`, `zipcode_to`) - SELECT r.`id_tax_rules_group`, r.`id_country`, r.`id_state`, r.`id_tax`, 0, z.`from_zip_code`, z.`to_zip_code` - FROM `'._DB_PREFIX_.'tax_rule` r INNER JOIN `'._DB_PREFIX_.'county_zip_code` z ON (z.`id_county` = r.`id_county`) - '); - - // update behavior - Db::getInstance()->Execute(' - UPDATE `'._DB_PREFIX_.'tax_rule` SET `behavior` = GREATEST(`state_behavior`, `county_behavior`); - '); - - - // Clean old entries - Db::getInstance()->Execute(' - DELETE FROM `'._DB_PREFIX_.'tax_rule` - WHERE `id_county` != 0 - AND `zipcode_from` = 0 - '); - - // Remove old columns - Db::getInstance()->Execute(' - ALTER TABLE `'._DB_PREFIX_.'tax_rule` - DROP `id_county`, - DROP `state_behavior`, - DROP `county_behavior` - '); -} - diff --git a/install-dev/sql/upgrade/1.5.0.1.sql b/install-dev/sql/upgrade/1.5.0.1.sql index 65a786574..8906205c5 100644 --- a/install-dev/sql/upgrade/1.5.0.1.sql +++ b/install-dev/sql/upgrade/1.5.0.1.sql @@ -33,7 +33,28 @@ INSERT INTO `PREFIX_hook` ( ) VALUES ('taxmanager', 'taxmanager', NULL , '1', '0'); -/* PHP:update_tax_rules(); */; +ALTER TABLE `PREFIX_tax_rule` + ADD `zipcode_from` INT NOT NULL AFTER `id_state` , + ADD `zipcode_to` INT NOT NULL AFTER `zipcode_from` , + ADD `behavior` INT NOT NULL AFTER `zipcode_to`, + ADD `description` VARCHAR( 100 ) NOT NULL AFTER `id_tax`; + +ALTER TABLE `PREFIX_tax_rule` DROP INDEX tax_rule; + +INSERT INTO `PREFIX_tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `id_tax`, `behavior`, `zipcode_from`, `zipcode_to`) + SELECT r.`id_tax_rules_group`, r.`id_country`, r.`id_state`, r.`id_tax`, 0, z.`from_zip_code`, z.`to_zip_code` + FROM `PREFIX_tax_rule` r INNER JOIN `PREFIX_county_zip_code` z ON (z.`id_county` = r.`id_county`); + +UPDATE `PREFIX_tax_rule` SET `behavior` = GREATEST(`state_behavior`, `county_behavior`); + +DELETE FROM `PREFIX_tax_rule` +WHERE `id_county` != 0 +AND `zipcode_from` = 0; + +ALTER TABLE `PREFIX_tax_rule` + DROP `id_county`, + DROP `state_behavior`, + DROP `county_behavior`; /* PHP:remove_tab(AdminCounty); */; DROP TABLE `PREFIX_county_zip_code`; diff --git a/install-dev/xml/doUpgrade.php b/install-dev/xml/doUpgrade.php index 812501710..6e2758fa3 100644 --- a/install-dev/xml/doUpgrade.php +++ b/install-dev/xml/doUpgrade.php @@ -133,8 +133,6 @@ require_once(_PS_INSTALLER_PHP_UPGRADE_DIR_.'create_multistore.php'); require_once(_PS_INSTALLER_PHP_UPGRADE_DIR_.'add_order_state.php'); -require_once(_PS_INSTALLER_PHP_UPGRADE_DIR_.'update_tax_rules.php'); - require_once(_PS_INSTALLER_PHP_UPGRADE_DIR_.'remove_tab.php'); //old version detection