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

ALTER TABLE `ATTIVITA` ADD COLUMN `flgEbay` INTEGER;


######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='261' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ATTIVITA"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ATTIVITA` ADD COLUMN `cciaa` VARCHAR(10);

ALTER TABLE `ATTIVITA` ADD COLUMN `faxAttivita` VARCHAR(40);

ALTER TABLE `ATTIVITA` MODIFY `capComuneAttivita` CHAR(5);






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

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

# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_VARIANTE"                                        #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_VARIANTE` ADD COLUMN `ebayOfferIdAv` VARCHAR(40);


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

ALTER TABLE `ATTIVITA` ADD COLUMN `ebayFulfillmentPolicyId` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `ebayPaymentPolicyId` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `ebayReturnPolicyId` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `ebayMerchantLocationKey` VARCHAR(40);


######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='262' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "USERS"                                                    #
# ---------------------------------------------------------------------- #

ALTER TABLE `USERS` MODIFY `imgTmst` VARCHAR(24);

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

ALTER TABLE `MARCA` MODIFY `imgTmst` VARCHAR(24);

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

ALTER TABLE `ARTICOLO` MODIFY `imgTmst` VARCHAR(24);

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

ALTER TABLE `CLIFOR` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "TIPO_PAGAMENTO"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO_PAGAMENTO` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "NEWS"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `NEWS` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "NEWSLETTER1"                                              #
# ---------------------------------------------------------------------- #

ALTER TABLE `NEWSLETTER1` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_VARIANTE"                                        #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_VARIANTE` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "TABELLA_TAGLIA"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `TABELLA_TAGLIA` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "BANNER"                                                   #
# ---------------------------------------------------------------------- #

ALTER TABLE `BANNER` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "CODA_MESSAGGI"                                            #
# ---------------------------------------------------------------------- #

ALTER TABLE `CODA_MESSAGGI` MODIFY `imgTmst` VARCHAR(24);

# ---------------------------------------------------------------------- #
# Alter table "TEMPLATE_MSG"                                             #
# ---------------------------------------------------------------------- #

ALTER TABLE `TEMPLATE_MSG` MODIFY `imgTmst` VARCHAR(24);

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

ALTER TABLE `ATTIVITA` MODIFY `imgTmst` VARCHAR(24);



######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='263' where codice='DB_VERSION';
######################################################################

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

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

# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_VARIANTE"                                        #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_VARIANTE` ADD COLUMN `flgQtaEbay1Av` INTEGER;

####


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

ALTER TABLE `ATTIVITA` ADD COLUMN `ebayOAuthRefreshToken` TEXT;

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

ALTER TABLE `ATTIVITA` ADD COLUMN `ebayOAuthUserToken` TEXT;

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





######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='264' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Drop foreign key constraints                                           #
# ---------------------------------------------------------------------- #



ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `TIPO_ARTICOLO`;

ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `IVA_ARTICOLO`;

ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `TIPO_TAGLIA_ARTICOLO`;

ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `ARTICOLO_VARIANTE_ARTICOLO`;

ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `TABELLA_TAGLIA_ARTICOLO`;

ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `TIPO_ACCESSORIO_ARTICOLO`;

ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `VETRINA_ARTICOLO`;

ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `TIPO_ARTICOLO_2`;

#ALTER TABLE `ARTICOLO` DROP FOREIGN KEY `CLIFOR_ARTICOLO_conf_default`;

ALTER TABLE `ACCESSORIO` DROP FOREIGN KEY `ARTICOLO_ACCESSORIO_Assoc`;

ALTER TABLE `ACCESSORIO` DROP FOREIGN KEY `ARTICOLO_ACCESSORIO`;

ALTER TABLE `CARATTERISTICA_ARTICOLO` DROP FOREIGN KEY `ARTICOLO_CARATTERISTICA_ARTICOLO`;

ALTER TABLE `RIGA_DOCUMENTO` DROP FOREIGN KEY `ARTICOLO_RIGA_DOCUMENTO`;

ALTER TABLE `ARTICOLO_VARIANTE` DROP FOREIGN KEY `ARTICOLO_ARTICOLO_VARIANTE`;

ALTER TABLE `ARTICOLO_FORNITORE` DROP FOREIGN KEY `ARTICOLO_ARTICOLO_FORNITORE`;

ALTER TABLE `ALLEGATO_ARTICOLO` DROP FOREIGN KEY `ARTICOLO_ALLEGATO_ARTICOLO`;

ALTER TABLE `LISTINO_PERS` DROP FOREIGN KEY `ARTICOLO_LISTINO_PERS`;

ALTER TABLE `RIVALUTAZIONE` DROP FOREIGN KEY `ARTICOLO_RIVALUTAZIONE`;

ALTER TABLE `LISTINO_SERVIZI_PERS` DROP FOREIGN KEY `ARTICOLO_LISTINO_SERVIZI_PERS`;

ALTER TABLE `ARTICOLO_TAGLIA` DROP FOREIGN KEY `ARTICOLO_ARTICOLO_TAGLIA`;

ALTER TABLE `ARTICOLO_COMPONENTE` DROP FOREIGN KEY `ARTICOLO_COMPOSIZIONE`;

ALTER TABLE `LISTINO_ARTICOLO` DROP FOREIGN KEY `ARTICOLO_LISTINO_ARTICOLO`;

ALTER TABLE `MOVIMENTO` DROP FOREIGN KEY `ARTICOLO_MOVIMENTO`;

ALTER TABLE `ARTICOLO_PROGETTISTA` DROP FOREIGN KEY `ARTICOLO_ARTICOLO_PROGETTISTA`;

ALTER TABLE `ARTICOLO_ARTICOLO_COMPONENTE` DROP FOREIGN KEY `ARTICOLO_COMP`;

ALTER TABLE `ARTICOLO_ARTICOLO_COMPONENTE` DROP FOREIGN KEY `ARTICOLO_PRINCIPALE`;

ALTER TABLE `ARTICOLO_ARTICOLO_TESSUTO` DROP FOREIGN KEY `ARTICOLO_ARTICOLO_ARTICOLO_TESSUTO`;

ALTER TABLE `DOCUMENTO` DROP FOREIGN KEY `ARTICOLO_DOCUMENTO`;

ALTER TABLE `KIT` DROP FOREIGN KEY `ARTICOLO_KIT_PRIMARIO`;

ALTER TABLE `KIT` DROP FOREIGN KEY `ARTICOLO_KIT_SECONDARIO`;

ALTER TABLE `ARTICOLO_USATO` DROP FOREIGN KEY `ARTICOLO_ARTICOLO_USATO`;

ALTER TABLE `WISHLIST` DROP FOREIGN KEY `ARTICOLO_WISHLIST`;

ALTER TABLE `QUOTAZIONE_ARTICOLO` DROP FOREIGN KEY `ARTICOLO_QUOTAZIONE_ARTICOLO`;

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

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

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

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `MARCA_ARTICOLO` 
    FOREIGN KEY (`id_marca`) REFERENCES `MARCA` (`id_marca`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `TIPO_ARTICOLO` 
    FOREIGN KEY (`id_tipo`) REFERENCES `TIPO` (`id_tipo`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `IVA_ARTICOLO` 
    FOREIGN KEY (`id_iva`) REFERENCES `IVA` (`id_iva`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `TIPO_TAGLIA_ARTICOLO` 
    FOREIGN KEY (`id_tipoTaglia`) REFERENCES `TIPO_TAGLIA` (`id_tipoTaglia`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `ARTICOLO_VARIANTE_ARTICOLO` 
    FOREIGN KEY (`id_articoloVarianteBase`) REFERENCES `ARTICOLO_VARIANTE` (`id_articoloVariante`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `TABELLA_TAGLIA_ARTICOLO` 
    FOREIGN KEY (`id_tabellaTaglia`) REFERENCES `TABELLA_TAGLIA` (`id_tabellaTaglia`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `TIPO_ACCESSORIO_ARTICOLO` 
    FOREIGN KEY (`id_tipoAccessorio`) REFERENCES `TIPO_ACCESSORIO` (`id_tipoAccessorio`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `VETRINA_ARTICOLO` 
    FOREIGN KEY (`id_vetrina`) REFERENCES `VETRINA` (`id_vetrina`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `TIPO_ARTICOLO_2` 
    FOREIGN KEY (`id_tipo2`) REFERENCES `TIPO` (`id_tipo`);

#ALTER TABLE `ARTICOLO` ADD CONSTRAINT `CLIFOR_ARTICOLO_conf_default` 
#    FOREIGN KEY (`id_confezionistaDefault`) REFERENCES `CLIFOR` (`id_clifor`);

ALTER TABLE `ARTICOLO` ADD CONSTRAINT `LISTINO_ARTICOLO_ebay` 
    FOREIGN KEY (`id_listinoEbay`) REFERENCES `LISTINO` (`id_listino`);

ALTER TABLE `ACCESSORIO` ADD CONSTRAINT `ARTICOLO_ACCESSORIO_Assoc` 
    FOREIGN KEY (`id_articoloAssociato`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ACCESSORIO` ADD CONSTRAINT `ARTICOLO_ACCESSORIO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `CARATTERISTICA_ARTICOLO` ADD CONSTRAINT `ARTICOLO_CARATTERISTICA_ARTICOLO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `RIGA_DOCUMENTO` ADD CONSTRAINT `ARTICOLO_RIGA_DOCUMENTO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_VARIANTE` ADD CONSTRAINT `ARTICOLO_ARTICOLO_VARIANTE` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_FORNITORE` ADD CONSTRAINT `ARTICOLO_ARTICOLO_FORNITORE` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ALLEGATO_ARTICOLO` ADD CONSTRAINT `ARTICOLO_ALLEGATO_ARTICOLO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `LISTINO_PERS` ADD CONSTRAINT `ARTICOLO_LISTINO_PERS` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `RIVALUTAZIONE` ADD CONSTRAINT `ARTICOLO_RIVALUTAZIONE` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `LISTINO_SERVIZI_PERS` ADD CONSTRAINT `ARTICOLO_LISTINO_SERVIZI_PERS` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_TAGLIA` ADD CONSTRAINT `ARTICOLO_ARTICOLO_TAGLIA` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_COMPONENTE` ADD CONSTRAINT `ARTICOLO_COMPOSIZIONE` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `LISTINO_ARTICOLO` ADD CONSTRAINT `ARTICOLO_LISTINO_ARTICOLO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `MOVIMENTO` ADD CONSTRAINT `ARTICOLO_MOVIMENTO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_PROGETTISTA` ADD CONSTRAINT `ARTICOLO_ARTICOLO_PROGETTISTA` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_ARTICOLO_COMPONENTE` ADD CONSTRAINT `ARTICOLO_COMP` 
    FOREIGN KEY (`id_articoloComponente`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_ARTICOLO_COMPONENTE` ADD CONSTRAINT `ARTICOLO_PRINCIPALE` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_ARTICOLO_TESSUTO` ADD CONSTRAINT `ARTICOLO_ARTICOLO_ARTICOLO_TESSUTO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `DOCUMENTO` ADD CONSTRAINT `ARTICOLO_DOCUMENTO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `KIT` ADD CONSTRAINT `ARTICOLO_KIT_PRIMARIO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `KIT` ADD CONSTRAINT `ARTICOLO_KIT_SECONDARIO` 
    FOREIGN KEY (`id_articoloSecondario`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_USATO` ADD CONSTRAINT `ARTICOLO_ARTICOLO_USATO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `WISHLIST` ADD CONSTRAINT `ARTICOLO_WISHLIST` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `QUOTAZIONE_ARTICOLO` ADD CONSTRAINT `ARTICOLO_QUOTAZIONE_ARTICOLO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);
	
	
	
### solo ccc
update ARTICOLO set id_listinoEbay=3;
	
	
######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='265' where codice='DB_VERSION';
######################################################################



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

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


	
######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='266' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "IVA"                                                      #
# ---------------------------------------------------------------------- #

ALTER TABLE `IVA` MODIFY `flgTipo` CHAR(2);


# ---------------------------------------------------------------------- #
# Alter table "TIPOLOGIA_DOCUMENTO"                                      #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPOLOGIA_DOCUMENTO` ADD COLUMN `flgTDFelett` VARCHAR(4);
update TIPOLOGIA_DOCUMENTO SET flgTDFelett='TD01' WHERE codice=1;
update TIPOLOGIA_DOCUMENTO SET flgTDFelett='TD04' WHERE codice=2;

######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='267' where codice='DB_VERSION';
######################################################################

# ---------------------------------------------------------------------- #
# Add table "ARTICOLO_CLIENTE"                                           #
# ---------------------------------------------------------------------- #

CREATE TABLE `ARTICOLO_CLIENTE` (
    `id_articoloCliente` INTEGER NOT NULL AUTO_INCREMENT,
    `id_clifor` INTEGER,
    `id_articolo` INTEGER,
    `id_articoloVariante` INTEGER,
    `id_tipo` INTEGER(11),
    CONSTRAINT `PK_ARTICOLO_CLIENTE` PRIMARY KEY (`id_articoloCliente`)
);

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

ALTER TABLE `ARTICOLO_CLIENTE` ADD CONSTRAINT `ARTICOLO_ARTICOLO_CLIENTE` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);

ALTER TABLE `ARTICOLO_CLIENTE` ADD CONSTRAINT `ARTICOLO_VARIANTE_ARTICOLO_CLIENTE` 
    FOREIGN KEY (`id_articoloVariante`) REFERENCES `ARTICOLO_VARIANTE` (`id_articoloVariante`);

ALTER TABLE `ARTICOLO_CLIENTE` ADD CONSTRAINT `TIPO_ARTICOLO_CLIENTE` 
    FOREIGN KEY (`id_tipo`) REFERENCES `TIPO` (`id_tipo`);

ALTER TABLE `ARTICOLO_CLIENTE` ADD CONSTRAINT `CLIFOR_ARTICOLO_CLIENTE` 
    FOREIGN KEY (`id_clifor`) REFERENCES `CLIFOR` (`id_clifor`);
	
	
	ALTER TABLE `ARTICOLO_CLIENTE` ADD COLUMN `indiciTipo` VARCHAR(1000);
	
	######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='268' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO"                                                 #
# ---------------------------------------------------------------------- #



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


update ARTICOLO SET qtaEbay=2 where flgQtaEbay1=1;
	ALTER TABLE `ARTICOLO` DROP COLUMN `flgQtaEbay1`;



# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_VARIANTE"                                        #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_VARIANTE` CHANGE `flgQtaEbay1Av` `qtaEbayAv` INTEGER;



	######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='269' where codice='DB_VERSION';
######################################################################

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

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

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

ALTER TABLE `ARTICOLO` ADD COLUMN `tmstLastImpression` DATETIME;

# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_VARIANTE"                                        #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_VARIANTE` ADD COLUMN `qtaSuEbayAv` INTEGER;

ALTER TABLE `ARTICOLO_VARIANTE` ADD COLUMN `impressionAv` INTEGER;

ALTER TABLE `ARTICOLO_VARIANTE` ADD COLUMN `tmstLastImpressionAv` DATETIME;

# ---------------------------------------------------------------------- #



	######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='270' where codice='DB_VERSION';
######################################################################


# ---------------------------------------------------------------------- #
# Alter table "TIPO_PAGAMENTO"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO_PAGAMENTO` ADD COLUMN `percWwwSconto` DECIMAL(5,2);

ALTER TABLE `TIPO_PAGAMENTO` ADD COLUMN `percWwwCommissione` DECIMAL(5,2);



	######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='271' where codice='DB_VERSION';
######################################################################


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


	######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='272' where codice='DB_VERSION';
######################################################################


# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_FORNITORE"                                       #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_FORNITORE` ADD COLUMN `costoAggiuntivo` DECIMAL(18,4);


	######################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='273' where codice='DB_VERSION';
######################################################################

alter table BLACKLIST add column ipMax integer unsigned;
alter table BLACKLIST add column ipMin integer unsigned;


#####################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='274' where codice='DB_VERSION';
######################################################################


# ---------------------------------------------------------------------- #
# Alter table "NAZIONE"                                                  #
# ---------------------------------------------------------------------- #
ALTER TABLE `NAZIONE` ADD COLUMN `flgGoogleMerchant` INTEGER;
update NAZIONE SET flgGoogleMerchant=1;

###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='275' where codice='DB_VERSION';
######################################################################


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

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



ALTER TABLE `ARTICOLO` ADD CONSTRAINT `CLIFOR_ARTICOLO_forn_costo_nuovo` 
    FOREIGN KEY (`id_fornitoreCostoNuovo`) REFERENCES `CLIFOR` (`id_clifor`);
	
	
	
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_FORNITORE"                                       #
# ---------------------------------------------------------------------- #



CREATE UNIQUE INDEX `IDX_ARTICOLO_FORNITORE_2` ON `ARTICOLO_FORNITORE` (`codiceFornitore`,`id_clifor`);

	
###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='276' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `googleProductCategory` INTEGER;


	
# ---------------------------------------------------------------------- #
# Add table "GOOGLE_CATEGORY"                                            #
# ---------------------------------------------------------------------- #

CREATE TABLE `GOOGLE_CATEGORY` (
    `id_googleCategory` INTEGER NOT NULL AUTO_INCREMENT,
    `codice` INTEGER,
    `descrizione` VARCHAR(1000),
    CONSTRAINT `PK_GOOGLE_CATEGORY` PRIMARY KEY (`id_googleCategory`)
);

CREATE INDEX `IDX_GOOGLE_CATEGORY_1` ON `GOOGLE_CATEGORY` (`descrizione`);

CREATE UNIQUE INDEX `IDX_GOOGLE_CATEGORY_2` ON `GOOGLE_CATEGORY` (`codice`);



# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `id_googleCategory` INTEGER;


ALTER TABLE `TIPO` ADD CONSTRAINT `GOOGLE_CATEGORY_TIPO` 
    FOREIGN KEY (`id_googleCategory`) REFERENCES `GOOGLE_CATEGORY` (`id_googleCategory`);

###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='277' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ATTIVITA"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ATTIVITA` ADD COLUMN `flgIcecat` INTEGER;

ALTER TABLE `ATTIVITA` ADD COLUMN `icecatUsername` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `icecatPassword` VARCHAR(40);

###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='278' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "CARATTERISTICA"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `CARATTERISTICA` ADD COLUMN `icecatDescs` VARCHAR(250);

CREATE INDEX `IDX_CARATTERISTICA_2` ON `CARATTERISTICA` (`icecatDescs`);

# ---------------------------------------------------------------------- #
# Alter table "LISTA"                                                    #
# ---------------------------------------------------------------------- #

ALTER TABLE `LISTA` ADD COLUMN `icecatValues` VARCHAR(250);

CREATE INDEX `IDX_LISTA_2` ON `LISTA` (`icecatValues`);


###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='279' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO"                                                 #
# ---------------------------------------------------------------------- #

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

# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_VARIANTE"                                        #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_VARIANTE` ADD COLUMN `id_statoUsato` INTEGER;

# ---------------------------------------------------------------------- #
# Add table "STATO_USATO"                                                #
# ---------------------------------------------------------------------- #

CREATE TABLE `STATO_USATO` (
    `id_statoUsato` INTEGER NOT NULL AUTO_INCREMENT,
    `sigla` CHAR(2),
    CONSTRAINT `PK_STATO_USATO` PRIMARY KEY (`id_statoUsato`)
);


ALTER TABLE `ARTICOLO` ADD CONSTRAINT `STATO_USATO_ARTICOLO` 
    FOREIGN KEY (`id_statoUsato`) REFERENCES `STATO_USATO` (`id_statoUsato`);


ALTER TABLE `ARTICOLO_VARIANTE` ADD CONSTRAINT `STATO_USATO_ARTICOLO_VARIANTE` 
    FOREIGN KEY (`id_statoUsato`) REFERENCES `STATO_USATO` (`id_statoUsato`);
	
	# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `ebayCommissione` DECIMAL(5,2);


# ---------------------------------------------------------------------- #
# Alter table "STATO_USATO"                                              #
# ---------------------------------------------------------------------- #

CREATE UNIQUE INDEX `IDX_STATO_USATO_1` ON `STATO_USATO` (`sigla`);

# ---------------------------------------------------------------------- #
# Alter table "STATO_USATO"                                              #
# ---------------------------------------------------------------------- #

ALTER TABLE `STATO_USATO` ADD COLUMN `flgLivello` INTEGER;



# ---------------------------------------------------------------------- #
# Alter table "NAZIONE"                                                  #
# ---------------------------------------------------------------------- #

ALTER TABLE `NAZIONE` ADD COLUMN `flgPreventivoWww` INTEGER;

	
###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='280' where codice='DB_VERSION';
######################################################################

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


# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_VARIANTE"                                        #
# ---------------------------------------------------------------------- #


# ---------------------------------------------------------------------- #
# Add table "STATO_USATO"                                                #
# ---------------------------------------------------------------------- #


#ALTER TABLE `ARTICOLO` ADD CONSTRAINT `STATO_USATO_ARTICOLO` 
#    FOREIGN KEY (`id_statoUsato`) REFERENCES `STATO_USATO` (`id_statoUsato`);


#ALTER TABLE `ARTICOLO_VARIANTE` ADD CONSTRAINT `STATO_USATO_ARTICOLO_VARIANTE` 
#    FOREIGN KEY (`id_statoUsato`) REFERENCES `STATO_USATO` (`id_statoUsato`);
	
	# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #




# ---------------------------------------------------------------------- #
# Alter table "STATO_USATO"                                              #
# ---------------------------------------------------------------------- #

#CREATE UNIQUE INDEX `IDX_STATO_USATO_1` ON `STATO_USATO` (`sigla`);

# ---------------------------------------------------------------------- #
# Alter table "STATO_USATO"                                              #
# ---------------------------------------------------------------------- #




# ---------------------------------------------------------------------- #
# Alter table "NAZIONE"                                                  #
# ---------------------------------------------------------------------- #



	
###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='280' where codice='DB_VERSION';
######################################################################


# ---------------------------------------------------------------------- #

# Alter table "ARTICOLO"                                                 #

# ---------------------------------------------------------------------- #



ALTER TABLE `ARTICOLO` DROP COLUMN `costoSpedizione`;



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



# ---------------------------------------------------------------------- #

# Add table "ARTICOLO_NAZIONE"                                           #

# ---------------------------------------------------------------------- #



CREATE TABLE `ARTICOLO_NAZIONE` (

    `id_articoloNazione` INTEGER NOT NULL AUTO_INCREMENT,

    `id_nazione` CHAR(4),

    `id_articolo` INTEGER,

    `flgPreventivoWwwAN` INTEGER,

    `costoSpedizioneAN` DECIMAL(18,4),

    CONSTRAINT `PK_ARTICOLO_NAZIONE` PRIMARY KEY (`id_articoloNazione`)

);

ALTER TABLE `ARTICOLO_NAZIONE` ADD CONSTRAINT `NAZIONE_ARTICOLO_NAZIONE` 

    FOREIGN KEY (`id_nazione`) REFERENCES `NAZIONE` (`id_nazione`);



ALTER TABLE `ARTICOLO_NAZIONE` ADD CONSTRAINT `ARTICOLO_ARTICOLO_NAZIONE` 

    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);
	
	

# ---------------------------------------------------------------------- #

# Alter table "ARTICOLO"                                                 #

# ---------------------------------------------------------------------- #



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



# ---------------------------------------------------------------------- #

# Alter table "ATTIVITA"                                                 #

# ---------------------------------------------------------------------- #



ALTER TABLE `ATTIVITA` ADD COLUMN `flgPercSpedizioneSuperato` INTEGER;


ALTER TABLE `ATTIVITA` CHANGE `flgPercSpedizioneSuperato` `percentileMaxPerPreventivo` INTEGER;

	
	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='281' where codice='DB_VERSION';
######################################################################

ALTER TABLE `ARTICOLO_VARIANTE` ADD COLUMN `codiceEanAv` VARCHAR(40);
	
	
	
# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `percCostoSpedizioneDefault` INTEGER;

update ARTICOLO SET percCostoSpedizione=0  where percCostoSpedizione<=10;


	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='282' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #
# Alter table "LISTINO_ARTICOLO"                                         #
# ---------------------------------------------------------------------- #

ALTER TABLE `LISTINO_ARTICOLO` ADD COLUMN `percScontoOffertaLA` DECIMAL(5,2);



# ---------------------------------------------------------------------- #
# Alter table "IVA"                                                      #
# ---------------------------------------------------------------------- #

ALTER TABLE `IVA` ADD COLUMN `flgOss` INTEGER;

# ---------------------------------------------------------------------- #
# Alter table "NAZIONE"                                                  #
# ---------------------------------------------------------------------- #

ALTER TABLE `NAZIONE` ADD COLUMN `id_iva` INTEGER;



ALTER TABLE `NAZIONE` ADD CONSTRAINT `IVA_NAZIONE` 
    FOREIGN KEY (`id_iva`) REFERENCES `IVA` (`id_iva`);
	
	
	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='283' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "IVA"                                                      #
# ---------------------------------------------------------------------- #

ALTER TABLE `IVA` ADD COLUMN `id_ivaStdRM` INTEGER;

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

ALTER TABLE `IVA` ADD CONSTRAINT `IVA_IVA_std_regime_margine` 
    FOREIGN KEY (`id_ivaStdRM`) REFERENCES `IVA` (`id_iva`);
	
	
	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='284' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #
# Alter table "CLIFOR"                                                   #
# ---------------------------------------------------------------------- #

ALTER TABLE `CLIFOR` ADD COLUMN `flgAbilitaAF` INTEGER;


	
	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='285' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "DOCUMENTO"                                                #
# ---------------------------------------------------------------------- #

ALTER TABLE `DOCUMENTO` ADD COLUMN `notaMail` VARCHAR(2000);
	
	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='286' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #
# Alter table "DOCUMENTO"                                                #
# ---------------------------------------------------------------------- #

ALTER TABLE `DOCUMENTO` ADD COLUMN `flgWwwTipoOrdine` INTEGER;

ALTER TABLE `DOCUMENTO` ADD COLUMN `wwwCostoOrdine` DECIMAL(18,4);

ALTER TABLE `DOCUMENTO` ADD COLUMN `wwwCostoSpedizione` DECIMAL(18,4);

ALTER TABLE `DOCUMENTO` ADD COLUMN `wwwCostoTariffa` DECIMAL(18,4);

	

# ---------------------------------------------------------------------- #
# Alter table "TIPO_PAGAMENTO"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO_PAGAMENTO` ADD COLUMN `wwwCommissionePercDefault` DECIMAL(5,2);

ALTER TABLE `TIPO_PAGAMENTO` ADD COLUMN `wwwTariffaFissa` DECIMAL(18,4);


ALTER TABLE `DOCUMENTO` ADD COLUMN `id_rigaBollaAtr` INTEGER;

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='286' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO` ADD COLUMN `categoriaImport` VARCHAR(1000);
insert into TIPOLOGIA_DOCUMENTO (id_tipologiaDocumento, codice, descrizione) values (151,151,'RICEVUTA A CREDITO');

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='288' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #
# Alter table "ATTIVITA"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ATTIVITA` ADD COLUMN `googleMerchantRecensioniScript` VARCHAR(2000);

ALTER TABLE `ATTIVITA` ADD COLUMN `googleMerchantRecensioniScriptBadge` VARCHAR(2000);
     
ALTER TABLE `ATTIVITA` ADD COLUMN `flgGoogleMerchantRecensioni` INTEGER;

ALTER TABLE `ATTIVITA` ADD COLUMN `flgGoogleMerchantRecensioniBadge` INTEGER;


	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='289' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_FORNITORE"                                       #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_FORNITORE` ADD COLUMN `dataInizioPromo` DATE;

ALTER TABLE `ARTICOLO_FORNITORE` ADD COLUMN `dataFinePromo` DATE;


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

ALTER TABLE `ARTICOLO` ADD COLUMN `dataScadenzaOffertaFornitore` DATE;

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='290' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ATTIVITA"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `ATTIVITA` ADD COLUMN `googleSiteId` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `googleApiKey` VARCHAR(250);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzAccessKeyId` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzSecretKey` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzRoleArn` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzRoleSessionName` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzClientId` VARCHAR(40);

ALTER TABLE `ATTIVITA` ADD COLUMN `amzClientSecret` VARCHAR(40);

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

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='291' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO"                                                 #
# ---------------------------------------------------------------------- #

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

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

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

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




ALTER TABLE `ARTICOLO` ADD CONSTRAINT `LISTINO_ARTICOLO_amz` 
    FOREIGN KEY (`id_listinoAmazon`) REFERENCES `LISTINO` (`id_listino`);


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

ALTER TABLE `ATTIVITA` ADD COLUMN `flgAmz` INTEGER;

ALTER TABLE `ATTIVITA` ADD COLUMN `id_listinoAmz` INTEGER;

ALTER TABLE `ATTIVITA` ADD CONSTRAINT `LISTINO_ATTIVITA_amz` 
    FOREIGN KEY (`id_listinoAmz`) REFERENCES `LISTINO` (`id_listino`);





# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `amazonCommissione` DECIMAL(5,2);



# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `amazonSoglia` DECIMAL(18,4);

ALTER TABLE `TIPO` ADD COLUMN `amazonCommissioneOltreSoglia` DECIMAL(5,2);


#### QUESTO NON LO TROVO !!!!!!!!!! MA C'è DA UN BEL PO'
ALTER TABLE `TIPO_PAGAMENTO` ADD COLUMN `flgTipoPagamentoEcommerce` INTEGER;


	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='292' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_NAZIONE"                                         #
# ---------------------------------------------------------------------- #

CREATE UNIQUE INDEX `IDX_ARTICOLO_NAZIONE_1` ON `ARTICOLO_NAZIONE` (`id_nazione`,`id_articolo`);

# ---------------------------------------------------------------------- #
# Add table "CATEGORIA_INGRAMMICRO"                                      #
# ---------------------------------------------------------------------- #

CREATE TABLE `CATEGORIA_INGRAMMICRO` (
    `id_categoriaIngrammiro` INTEGER NOT NULL AUTO_INCREMENT,
    `descrizione` VARCHAR(254),
    `codice` VARCHAR(8),
    CONSTRAINT `PK_CATEGORIA_INGRAMMICRO` PRIMARY KEY (`id_categoriaIngrammiro`)
);

CREATE UNIQUE INDEX `IDX_CATEGORIA_INGRAMMICRO_1` ON `CATEGORIA_INGRAMMICRO` (`codice`);

######

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='292' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "WISHLIST"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `WISHLIST` ADD COLUMN `dispoLevelWL` INTEGER;

ALTER TABLE `WISHLIST` ADD COLUMN `dispoLevelUltimoAvviso` INTEGER;

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='294' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #

# Add table "REMOTE_DEVICE"                                              #

# ---------------------------------------------------------------------- #



CREATE TABLE `REMOTE_DEVICE` (

    `id_remoteDevice` INTEGER NOT NULL AUTO_INCREMENT,

    `descrizione` VARCHAR(60),

    `token` VARCHAR(512),

    `imei` VARCHAR(40),

    `ipAddress` CHAR(60),

    `updTmst` TIMESTAMP,

    CONSTRAINT `PK_REMOTE_DEVICE` PRIMARY KEY (`id_remoteDevice`)

);



# ---------------------------------------------------------------------- #
# Alter table "REMOTE_DEVICE"                                            #
# ---------------------------------------------------------------------- #

ALTER TABLE `REMOTE_DEVICE` ADD COLUMN `imgTmst` VARCHAR(24);

ALTER TABLE `REMOTE_DEVICE` MODIFY `updTmst` DATETIME;
ALTER TABLE `REMOTE_DEVICE` add column `flgAbilitato` integer;


# ---------------------------------------------------------------------- #
# Alter table "CODA_MESSAGGI"                                            #
# ---------------------------------------------------------------------- #

ALTER TABLE `CODA_MESSAGGI` ADD COLUMN `id_remoteDevice` INTEGER;

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


ALTER TABLE `CODA_MESSAGGI` ADD CONSTRAINT `REMOTE_DEVICE_CODA_MESSAGGI` 
    FOREIGN KEY (`id_remoteDevice`) REFERENCES `REMOTE_DEVICE` (`id_remoteDevice`);
	
	
	# ---------------------------------------------------------------------- #
# Alter table "REMOTE_DEVICE"                                            #
# ---------------------------------------------------------------------- #

ALTER TABLE `REMOTE_DEVICE` ADD COLUMN `fcmToken` VARCHAR(512);

CREATE UNIQUE INDEX `IDX_REMOTE_DEVICE_1` ON `REMOTE_DEVICE` (`token`);

CREATE UNIQUE INDEX `IDX_REMOTE_DEVICE_2` ON `REMOTE_DEVICE` (`fcmToken`);

CREATE UNIQUE INDEX `IDX_REMOTE_DEVICE_3` ON `REMOTE_DEVICE` (`imei`);

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='295' where codice='DB_VERSION';
####################################################################### Alter table "ARTICOLO"                                                 #
# ---------------------------------------------------------------------- #

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

# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `flgControlloCostiAggFor` INTEGER;

# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_FORNITORE"                                       #
# ---------------------------------------------------------------------- #

ALTER TABLE `ARTICOLO_FORNITORE` ADD COLUMN `flgControlloCostoAggAF` INTEGER;








	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='296' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #

# Alter table "CLIFOR"                                                   #

# ---------------------------------------------------------------------- #



ALTER TABLE `CLIFOR` ADD COLUMN `importLinkFornitoreEan` VARCHAR(254);



	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.297' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "MARCA"                                                    #
# ---------------------------------------------------------------------- #

ALTER TABLE `MARCA` ADD COLUMN `tagOfferta` VARCHAR(40);



	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.298' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "TIPO_PAGAMENTO"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO_PAGAMENTO` ADD COLUMN `tariffaAggiuntiva` DECIMAL(18,4);




	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.299' where codice='DB_VERSION';
######################################################################


ALTER TABLE `TIPO_DOCUMENTO` ADD COLUMN `flgOss` INTEGER;




	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.300' where codice='DB_VERSION';
######################################################################
CREATE TABLE `CLIFOR_TIPO_PAGAMENTO` (
    `id_cliforTipoPagamento` INTEGER NOT NULL AUTO_INCREMENT,
    `id_clifor` INTEGER NOT NULL,
    `id_tipoPagamento` INTEGER NOT NULL,
    CONSTRAINT `PK_CLIFOR_TIPO_PAGAMENTO` PRIMARY KEY (`id_cliforTipoPagamento`)
);

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

ALTER TABLE `CLIFOR_TIPO_PAGAMENTO` ADD CONSTRAINT `CLIFOR_CLIFOR_TIPO_PAGAMENTO` 
    FOREIGN KEY (`id_clifor`) REFERENCES `CLIFOR` (`id_clifor`);

ALTER TABLE `CLIFOR_TIPO_PAGAMENTO` ADD CONSTRAINT `TIPO_PAGAMENTO_CLIFOR_TIPO_PAGAMENTO` 
    FOREIGN KEY (`id_tipoPagamento`) REFERENCES `TIPO_PAGAMENTO` (`id_tipoPagamento`);
	
CREATE UNIQUE INDEX `IDX_CLIFOR_TIPO_PAGAMENTO_1` ON `CLIFOR_TIPO_PAGAMENTO` (`id_clifor`,`id_tipoPagamento`);

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.301' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO"                                                 #
# ---------------------------------------------------------------------- #

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


# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `trovaprezziCategoria` VARCHAR(254);

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

ALTER TABLE `ATTIVITA` ADD COLUMN `flgTrovaprezzi` INTEGER;


	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.302' where codice='DB_VERSION';
######################################################################

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

ALTER TABLE `ATTIVITA` ADD COLUMN `trovaprezziTrustedProgramScript` VARCHAR(2000);
ALTER TABLE `ATTIVITA` ADD COLUMN `trovaprezziTrustedProgramScriptItem` VARCHAR(200);

	###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.303' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #
# Alter table "NAZIONE"                                                  #
# ---------------------------------------------------------------------- #

ALTER TABLE `NAZIONE` ADD COLUMN `importoMinimoWww` DECIMAL(18,4);

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

ALTER TABLE `ATTIVITA` ADD COLUMN `checkCartPercScontoMax` DECIMAL(5,2);

ALTER TABLE `ATTIVITA` ADD COLUMN `cookiePolicyTheme` VARCHAR(60);
###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.304' where codice='DB_VERSION';
######################################################################
ALTER TABLE `NAZIONE` ADD COLUMN `tag` VARCHAR(254);


ALTER TABLE `ATTIVITA` ADD COLUMN `flgIdealo` INTEGER;

ALTER TABLE `ATTIVITA` ADD COLUMN `idealoTag` VARCHAR(40);

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

###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.305' where codice='DB_VERSION';
####################################################################### ---------------------------------------------------------------------- #
# Alter table "USERS"                                                    #
# ---------------------------------------------------------------------- #

ALTER TABLE `USERS` ADD COLUMN `costoOrario` DECIMAL(18,4);

ALTER TABLE `USERS` ADD COLUMN `percServizi` DECIMAL(5,2);



ALTER TABLE `USERS` CHANGE `costoOrario` `tariffaProfessionista` DECIMAL(18,4);

ALTER TABLE `USERS` CHANGE `percServizi` `percProfessinista` DECIMAL(5,2);


###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.306' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ARTICOLO_FORNITORE"                                       #
# ---------------------------------------------------------------------- #

DROP INDEX `IDX_ARTICOLO_FORNITORE1` ON `ARTICOLO_FORNITORE`;

DROP INDEX `IDX_ARTICOLO_FORNITORE_2` ON `ARTICOLO_FORNITORE`;

ALTER TABLE `ARTICOLO_FORNITORE` MODIFY `codiceFornitore` VARCHAR(30);

CREATE UNIQUE INDEX `IDX_ARTICOLO_FORNITORE1` ON `ARTICOLO_FORNITORE` (`codiceFornitore` ASC,`id_clifor` ASC);

CREATE UNIQUE INDEX `IDX_ARTICOLO_FORNITORE_2` ON `ARTICOLO_FORNITORE` (`codiceFornitore`,`id_clifor`);



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

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

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

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




###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.307' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "USERS"                                                    #
# ---------------------------------------------------------------------- #


ALTER TABLE `USERS` ADD COLUMN `socialId` VARCHAR(60);

ALTER TABLE `USERS` ADD COLUMN `flgSocialIdType` INTEGER;

update attivita set flgdefault=1;

###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.308' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ACCESS"                                                   #
# ---------------------------------------------------------------------- #

ALTER TABLE `ACCESS` DROP COLUMN `versione`;

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

ALTER TABLE `ARTICOLO` DROP COLUMN `seoDesc`;

ALTER TABLE `ARTICOLO` DROP COLUMN `seoH1`;

ALTER TABLE `ARTICOLO` DROP COLUMN `seoTitle`;



ALTER TABLE `TIPO` DROP COLUMN `seoTitle`;

ALTER TABLE `TIPO` DROP COLUMN `seoDesc`;

ALTER TABLE `TIPO` DROP COLUMN `seoH1`;


ALTER TABLE `ARTICOLO` ADD COLUMN `nomeSeo` VARCHAR(30);

ALTER TABLE `ARTICOLO` ADD COLUMN `erroriSeo` VARCHAR(254);


# ---------------------------------------------------------------------- #
# Alter table "TIPO"                                                     #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO` ADD COLUMN `flgMainPage` INTEGER;


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

ALTER TABLE `ATTIVITA` ADD COLUMN `nomeAttivitaSeo` VARCHAR(30);

UPDATE DESC_TXT_LANG SET	 campo="metaDescTemplateLeaf" where tabella ='TIPO' and campo="metaDescTemplate";


###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.309' where codice='DB_VERSION';
######################################################################
# ---------------------------------------------------------------------- #
# Alter table "ATTIVITA"                                                 #
# ---------------------------------------------------------------------- #

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

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


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

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

ALTER TABLE `ATTIVITA` CHANGE `paypalRateScriptBody` `paypalRateScriptBodyDett` VARCHAR(1000);


###################################################################
#insert into PARM (codice) values ('DB_VERSION');
UPDATE PARM SET testo='Abl.310' where codice='DB_VERSION';
######################################################################