From 4323114a891bf37a73c27eb763ff9e38f5ebccb8 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 29 Feb 2008 22:55:11 +0000 Subject: [PATCH] Migrate old tax data into the nex tax data script. Tested this manually and it works okay. --- docs/upgrades/upgrade_7.5.2-7.5.3.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/upgrades/upgrade_7.5.2-7.5.3.pl b/docs/upgrades/upgrade_7.5.2-7.5.3.pl index 4d62c2a9a..f02cd6941 100644 --- a/docs/upgrades/upgrade_7.5.2-7.5.3.pl +++ b/docs/upgrades/upgrade_7.5.2-7.5.3.pl @@ -25,6 +25,7 @@ my $session = start(); # this line required # upgrade functions go here insertCommerceTaxTable($session); +migrateOldTaxTable($session); insertCommerceShipDriverTable($session); migrateToNewCart($session); createSkuAsset($session); @@ -157,6 +158,22 @@ EOSQL } +#------------------------------------------------- +sub migrateOldTaxTable { + my $session = shift; + print "\tMigrate old tax data into the new tax table.\n" unless ($quiet); + # and here's our code + my $oldTax = $session->db->prepare('select * from commerceSalesTax'); + my $newTax = $session->db->prepare('insert into tax (taxId, field, value, taxRate) VALUES (?,?,?,?)'); + $oldTax->execute(); + while (my $oldTaxData = $oldTax->hashRef()) { + $newTax->execute([$oldTaxData->{commerceSalesTaxId}, 'state', $oldTaxData->{regionIdentifier}, $oldTaxData->{salesTax}]); + } + $oldTax->finish; + $newTax->finish; + $session->db->write('drop table commerceSalesTax'); +} + #------------------------------------------------- sub insertCommerceShipDriverTable { my $session = shift;