
# ---------------------------------------------------------------------- #
# Alter table "MARCA"                                                    #
# ---------------------------------------------------------------------- #

ALTER TABLE `MARCA` ADD COLUMN `flgAmazon` INTEGER;

# ---------------------------------------------------------------------- #
# Alter table "CLIFOR"                                                   #
# ---------------------------------------------------------------------- #

ALTER TABLE `CLIFOR` ADD COLUMN `costoMinimoOrdineWeb` DECIMAL(18,4);

# ---------------------------------------------------------------------- #
# Alter table "ATTIVITA"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ATTIVITA` DROP COLUMN `amzAccessKeyId`;

ALTER TABLE `ATTIVITA` DROP COLUMN `amzSecretKey`;

ALTER TABLE `ATTIVITA` DROP COLUMN `amzRoleArn`;

ALTER TABLE `ATTIVITA` DROP COLUMN `amzRoleSessionName`;

ALTER TABLE `ATTIVITA` DROP COLUMN `amzClientId`;

ALTER TABLE `ATTIVITA` DROP COLUMN `amzClientSecret`;

ALTER TABLE `ATTIVITA` DROP COLUMN `amzRefreshToken`;

ALTER TABLE `ATTIVITA` ADD COLUMN `amzLwaClientId` VARCHAR(254);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzLwaClientSecret` VARCHAR(254);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzLwaAuthToken` VARCHAR(400);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzLwaAccessToken` VARCHAR(400);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzLwaRefreshToken` VARCHAR(400);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzLwaAccessTokenExpireTS` DATETIME;

ALTER TABLE `ATTIVITA` ADD COLUMN `amzIamRoleARN` VARCHAR(254);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzIamAccessKey` VARCHAR(254);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzIamSecretKey` VARCHAR(254);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzStsAccessKeyId` VARCHAR(254);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzStsSecretAccessKey` VARCHAR(254);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzStsSessionToken` VARCHAR(400);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzStsSessionTokenTS` DATETIME;

DROP INDEX `IDX_USERS_2` ON `USERS`;

ALTER TABLE `USERS` MODIFY `utenteDominio` VARCHAR(60);

CREATE UNIQUE INDEX `IDX_USERS_2` ON `USERS` (`utenteDominio`);


# ---------------------------------------------------------------------- #
# Alter table "ATTIVITA"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ATTIVITA` ADD COLUMN `amzMarketplaces` VARCHAR(1000);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzSellerid` VARCHAR(60);

# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO` ADD COLUMN `prezzoSuAmzIva` DECIMAL(18,4);

ALTER TABLE `ARTICOLO` ADD COLUMN `qtaSuAmz` INTEGER;

ALTER TABLE `ARTICOLO` ADD COLUMN `qtaAmz` INTEGER;

ALTER TABLE `ARTICOLO` ADD COLUMN `productTypeAmz` VARCHAR(40);

ALTER TABLE `ARTICOLO` ADD COLUMN `flgAmazonCatalog` INTEGER;


ALTER TABLE `ARTICOLO` ADD COLUMN `asinAmz` VARCHAR(40);
ALTER TABLE `ARTICOLO` ADD COLUMN `flgPriceTypeAmz` INTEGER;

ALTER TABLE `ARTICOLO` DROP COLUMN `flgAmazonCatalog`;

ALTER TABLE `ATTIVITA` ADD COLUMN `amzMerchantShippingGroupFree` VARCHAR(60);

ALTER TABLE `ARTICOLO` ADD COLUMN `descAmz` VARCHAR(1000);
ALTER TABLE `ARTICOLO` ADD COLUMN `flgAmzWarn` INTEGER;


# ---------------------------------------------------------------------- #
# Add table "AMZ_FEATURED_PRICE"                                         #
# ---------------------------------------------------------------------- #

CREATE TABLE `AMZ_FEATURED_PRICE` (
    `id_amzFeaturedPrice` INTEGER NOT NULL AUTO_INCREMENT,
    `id_articolo` INTEGER,
    `lang` VARCHAR(4),
    `featuredOEPriceAmz` DECIMAL(18,4),
    `competingFOPriceAmz` DECIMAL(18,4),
    `currentFOPriceAmz` DECIMAL(18,4),
    `currentPriceAmz` DECIMAL(18,4),
	`dataPriceAmz` DATE,
    CONSTRAINT `PK_AMZ_FEATURED_PRICE` PRIMARY KEY (`id_amzFeaturedPrice`)
);


CREATE UNIQUE INDEX `IDX_AMZ_FEATURED_PRICE_1` ON `AMZ_FEATURED_PRICE` (`id_articolo`,`lang`);

# ---------------------------------------------------------------------- #
# Add foreign key constraints                                            #
# ---------------------------------------------------------------------- #

ALTER TABLE `AMZ_FEATURED_PRICE` ADD CONSTRAINT `ARTICOLO_AMZ_FEATURED_PRICE` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);
	
	
# ---------------------------------------------------------------------- #
# Alter table "AMZ_FEATURED_PRICE"                                       #
# ---------------------------------------------------------------------- #

ALTER TABLE `AMZ_FEATURED_PRICE` ADD COLUMN `flgPrezzoCompetitivoAmz` INTEGER;

ALTER TABLE `AMZ_FEATURED_PRICE` ADD COLUMN `flgPrezzoCompetitivo` INTEGER;

