ALTER TABLE Products CHANGE ShippingLimitation ShippingLimitation TEXT NOT NULL, CHANGE AutomaticFilename AutomaticFilename TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', CHANGE `Type` `Type` TINYINT(2) UNSIGNED NOT NULL DEFAULT '1', CHANGE BackOrder BackOrder TINYINT UNSIGNED NOT NULL DEFAULT '2', CHANGE `Status` `Status` TINYINT(4) NOT NULL DEFAULT '2', CHANGE CreatedOn CreatedOn INT UNSIGNED NULL DEFAULT NULL, CHANGE Modified Modified INT UNSIGNED NULL DEFAULT NULL, CHANGE Expire Expire INT UNSIGNED NULL DEFAULT NULL, CHANGE CachedRating CachedRating DECIMAL(11,10) NOT NULL DEFAULT '0', CHANGE CachedReviewsQty CachedReviewsQty INT(11) NOT NULL DEFAULT '0', CHANGE QtyInStock QtyInStock INT(11) NOT NULL DEFAULT '0', CHANGE QtyReserved QtyReserved INT(11) NOT NULL DEFAULT '0', CHANGE QtyBackOrdered QtyBackOrdered INT(11) NOT NULL DEFAULT '0', CHANGE QtyOnOrder QtyOnOrder INT(11) NOT NULL DEFAULT '0';
ALTER TABLE Products DROP Filename;

ALTER TABLE ShippingType CHANGE Status Status TINYINT(4) NOT NULL DEFAULT '1', CHANGE CostType CostType TINYINT(4) NOT NULL DEFAULT '1', CHANGE ZeroIfEmpty ZeroIfEmpty TINYINT(4) NOT NULL DEFAULT '1', CHANGE PrecisionBeforeSep PrecisionBeforeSep TINYINT(4) NOT NULL DEFAULT '2', CHANGE PrecisionAfterSep PrecisionAfterSep TINYINT(4) NOT NULL DEFAULT '2', CHANGE LocationFrom LocationFrom INT(11) NOT NULL DEFAULT '1', CHANGE `Type` `Type` INT(11) NOT NULL DEFAULT '1';

ALTER TABLE AffiliatePlansItems CHANGE ItemType ItemType TINYINT(4) NOT NULL DEFAULT '1';
ALTER TABLE Orders CHANGE PortalUserId PortalUserId INT(11) NOT NULL DEFAULT '-1', CHANGE BillingCountry BillingCountry VARCHAR(255) NOT NULL DEFAULT 'USA', CHANGE ShippingCountry ShippingCountry VARCHAR(255) NOT NULL DEFAULT 'USA';
ALTER TABLE Affiliates CHANGE Status Status TINYINT(4) NOT NULL DEFAULT '2';
ALTER TABLE ShippingZones CHANGE CODallowed CODallowed SMALLINT(6) NOT NULL DEFAULT '1';

ALTER TABLE Affiliates CHANGE LastPaymentDate LastPaymentDate INT(11) UNSIGNED NULL DEFAULT NULL, CHANGE LastOrderDate LastOrderDate INT(11) UNSIGNED NULL DEFAULT NULL;
ALTER TABLE AffiliatePlans CHANGE PlanType PlanType TINYINT(3) UNSIGNED NOT NULL DEFAULT '1';
ALTER TABLE ProductsCoupons CHANGE Status Status TINYINT(4) NOT NULL DEFAULT '1', CHANGE `Type` `Type` TINYINT(1) NOT NULL DEFAULT '1', CHANGE NumberOfUses NumberOfUses INT(11) NOT NULL DEFAULT '1';
ALTER TABLE ProductsCouponItems CHANGE ItemType ItemType TINYINT(4) NOT NULL DEFAULT '1';
ALTER TABLE ProductsDiscountItems CHANGE ItemType ItemType TINYINT(4) NOT NULL DEFAULT '1';

ALTER TABLE ProductsDiscounts CHANGE `Status` `Status` TINYINT(4) NULL DEFAULT '2', CHANGE `Type` `Type` TINYINT(1) NULL DEFAULT '1';
ALTER TABLE ProductOptionCombinations CHANGE PriceType PriceType TINYINT(1) NULL DEFAULT '3', CHANGE WeightType WeightType TINYINT(1) NULL DEFAULT '3', CHANGE Availability Availability TINYINT(1) NULL DEFAULT '1';

ALTER TABLE ProductsPricing CHANGE Cost Cost DECIMAL(10, 4) NULL DEFAULT NULL, CHANGE Price Price DECIMAL(10, 4) NOT NULL DEFAULT '0';
ALTER TABLE PaymentTypes CHANGE ProcessingFee ProcessingFee DOUBLE NOT NULL DEFAULT '0';

ALTER TABLE ProductOptions CHANGE OptionType OptionType TINYINT(4) NOT NULL DEFAULT '0';

UPDATE Phrase SET Translation = REPLACE(Translation, CHAR(226), '');
UPDATE Phrase SET Translation = REPLACE(Translation, CHAR(128), '');
UPDATE Phrase SET Translation = REPLACE(Translation, CHAR(153), "'");

ALTER TABLE ProductOptionCombinations ADD QtyInStock int(11) NOT NULL default '0', ADD QtyReserved int(11) NOT NULL default '0', ADD QtyBackOrdered int(11) NOT NULL default '0', ADD QtyOnOrder int(11) NOT NULL default '0', ADD SKU varchar(255) NOT NULL default '';
ALTER TABLE ProductOptionCombinations CHANGE Availability Availability TINYINT(1) NOT NULL DEFAULT '1';

UPDATE Modules SET Version = '4.1.0' WHERE Name = 'In-Commerce';