# ---------------------------------------------------------------------- #
# Modify table "RIGA_DOCUMENTO"                                          #
# ---------------------------------------------------------------------- #

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `percL1` DECIMAL(5,2);

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `percL2` DECIMAL(5,2);

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `percL3` DECIMAL(5,2);

# ---------------------------------------------------------------------- #
# Modify table "LISTINO"                                                 #
# ---------------------------------------------------------------------- #

ALTER TABLE `LISTINO` ADD COLUMN `percL1` DECIMAL(5,2);

ALTER TABLE `LISTINO` ADD COLUMN `percL2` DECIMAL(5,2);

ALTER TABLE `LISTINO` ADD COLUMN `percL3` DECIMAL(5,2);

# ---------------------------------------------------------------------- #
# Modify table "TIPO_FORNITORE"                                          #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO_FORNITORE` CHANGE `flgAgente` `flgTipologia` INTEGER;

# ---------------------------------------------------------------------- #
# Add table "CLIFOR_ARTICOLO"                                            #
# ---------------------------------------------------------------------- #

CREATE TABLE `CLIFOR_ARTICOLO` (
    `id_cliforArticolo` INTEGER NOT NULL AUTO_INCREMENT,
    `percArticolo` DECIMAL(5,2),
    `id_progettista` INTEGER,
    `id_articolo` INTEGER,
    CONSTRAINT `PK_CLIFOR_ARTICOLO` PRIMARY KEY (`id_cliforArticolo`)
);

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

ALTER TABLE `CLIFOR_ARTICOLO` ADD CONSTRAINT `CLIFOR_CLIFOR_ARTICOLO` 
    FOREIGN KEY (`id_progettista`) REFERENCES `CLIFOR` (`id_clifor`);

ALTER TABLE `CLIFOR_ARTICOLO` ADD CONSTRAINT `ARTICOLO_CLIFOR_ARTICOLO` 
    FOREIGN KEY (`id_articolo`) REFERENCES `ARTICOLO` (`id_articolo`);