Put product update code in each upgrade script so they

don't fail.
This commit is contained in:
Colin Kuskie 2008-08-13 01:30:10 +00:00
parent 092c0a01da
commit 808fc1476b
11 changed files with 119 additions and 7 deletions

View file

@ -17,6 +17,7 @@
- fixed: Upgrade 7.5.10-7.5.11 upgrades transaction payment gateway info.
- fixed: Form CheckList select all button now functions properly
- fixed: Gallery slideshow JS now has better control over the buttons
- fixed: The bug enigmatically named "product".
7.5.19
- fixed: paginator doesn't show correct number of page links with a limit applied

View file

@ -32,6 +32,7 @@ use WebGUI::Utility;
use WebGUI::Pluggable;
use File::Path;
use JSON;
use Data::Dumper; #Don't ask my why, but there's an exposed call to this on line 2871
my $toVersion = "7.5.16"; # make this match what version you're going to
my $quiet; # this line required
@ -1206,6 +1207,7 @@ sub migrateOldProduct {
$session->db->write('alter table Product add column relatedJSON mediumtext');
$session->db->write('alter table Product add column specificationJSON mediumtext');
$session->db->write('alter table Product add column variantsJSON mediumtext');
$session->db->write('alter table Product add column isShippingRequired INT(11)');
##Build a variant for each Product.
my $productQuery = $session->db->read(<<EOSQL1);
SELECT p.assetId, p.price, p.productNumber, p.revisionDate, a.title, s.sku

View file

@ -1068,13 +1068,15 @@ sub migrateOldProduct {
$session->db->write(q!update asset set className='WebGUI::Asset::Sku::Product' where className='WebGUI::Asset::Wobject::Product'!);
## Add variants collateral column to Sku/Product
$session->db->write('alter table Product add column thankYouMessage mediumtext');
$session->db->write('alter table Product add column accessoryJSON mediumtext');
$session->db->write('alter table Product add column benefitJSON mediumtext');
$session->db->write('alter table Product add column featureJSON mediumtext');
$session->db->write('alter table Product add column relatedJSON mediumtext');
$session->db->write('alter table Product add column specificationJSON mediumtext');
$session->db->write('alter table Product add column variantsJSON mediumtext');
$session->db->write('alter table Product add column thankYouMessage mediumtext');
$session->db->write('alter table Product add column accessoryJSON mediumtext');
$session->db->write('alter table Product add column benefitJSON mediumtext');
$session->db->write('alter table Product add column featureJSON mediumtext');
$session->db->write('alter table Product add column relatedJSON mediumtext');
$session->db->write('alter table Product add column specificationJSON mediumtext');
$session->db->write('alter table Product add column variantsJSON mediumtext');
$session->db->write('alter table Product add column isShippingRequired INT(11)');
##Build a variant for each Product.
my $productQuery = $session->db->read(<<EOSQL1);
SELECT p.assetId, p.price, p.productNumber, p.revisionDate, a.title, s.sku

View file

@ -28,6 +28,7 @@ my $quiet; # this line required
my $session = start(); # this line required
maybeAddProductShippingColumn( $session );
fixShop($session);
addSelectableProfileTemplates($session);
addCouponThankYouMessage($session);
@ -99,6 +100,18 @@ sub addCouponThankYouMessage {
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------

View file

@ -31,6 +31,7 @@ my $session = start(); # this line required
# upgrade functions go here
deleteBadReceiptEmailTemplate($session);
unlockShelfAssets($session);
maybeAddProductShippingColumn( $session );
finish($session); # this line required
@ -71,6 +72,19 @@ sub deleteBadReceiptEmailTemplate {
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------

View file

@ -30,6 +30,7 @@ my $session = start(); # this line required
removeOldGalleryImport($session);
addMissingWorkflowActivities($session);
maybeAddProductShippingColumn( $session );
finish($session); # this line required
@ -54,6 +55,18 @@ sub removeOldGalleryImport {
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------

View file

@ -30,6 +30,7 @@ my $session = start(); # this line required
addIndexToInbox($session);
fixEventSequenceNumbers($session);
maybeAddProductShippingColumn( $session );
finish($session); # this line required
@ -51,6 +52,18 @@ sub fixEventSequenceNumbers {
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does

View file

@ -28,6 +28,7 @@ my $quiet; # this line required
my $session = start(); # this line required
moveProductImportToShelf($session);
maybeAddProductShippingColumn( $session );
finish($session); # this line required
@ -40,6 +41,18 @@ sub moveProductImportToShelf {
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------

View file

@ -31,6 +31,7 @@ my $session = start(); # this line required
# upgrade functions go here
nukeAnEmptyTemplate($session);
maybeAddProductShippingColumn( $session );
finish($session); # this line required
@ -47,6 +48,19 @@ sub nukeAnEmptyTemplate {
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {

View file

@ -36,6 +36,7 @@ addProductShipping( $session );
addGalleryImageDensity( $session );
updatePaymentDrivers( $session );
extendVendors($session);
maybeAddProductShippingColumn( $session );
finish($session); # this line required
@ -141,6 +142,19 @@ sub addNewInboxIndexes {
print "\n\t\tDONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------

View file

@ -29,6 +29,7 @@ my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
maybeAddProductShippingColumn( $session );
addThingyFieldsSizeColumn( $session );
finish($session); # this line required
@ -43,6 +44,18 @@ finish($session); # this line required
# print "DONE!\n" unless $quiet;
#}
#----------------------------------------------------------------------------
sub maybeAddProductShippingColumn {
my $session = shift;
print "\tAdd the isShippingColumn to the Product table, if needed... " unless $quiet;
my $sth = $session->db->read('describe Product isShippingRequired');
if (! defined $sth->hashRef) {
$session->db->write("ALTER TABLE Product add COLUMN isShippingRequired INT(11)");
}
print "Done!\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Add Thingy_fields size column
sub addThingyFieldsSizeColumn {