# ---------------------------------------------------------------------- #
# Script generated with: DeZign for Databases V7.3.4                     #
# Target DBMS:           MySQL 5                                         #
# Project file:          abliaDbComuni3.dez                              #
# Project name:          DB COMUNI - ABLIA                               #
# Author:                Andrea Colzi                                    #
# Script type:           Alter database script                           #
# Created on:            2016-12-12 09:43                                #
# ---------------------------------------------------------------------- #


# ---------------------------------------------------------------------- #
# Drop foreign key constraints                                           #
# ---------------------------------------------------------------------- #
# ---------------------------------------------------------------------- #
# Modify table "ACCESS"                                                  #
# ---------------------------------------------------------------------- #

ALTER TABLE `ACCESS` ADD COLUMN `flgDeleteCascade` INTEGER;

# ---------------------------------------------------------------------- #
# Modify table "LOG"                                                     #
# ---------------------------------------------------------------------- #

#154

# ---------------------------------------------------------------------- #
# Alter table "RIGA_DOCUMENTO"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `id_causaleMagazzino` INTEGER  DEFAULT null;

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `id_clifor` INTEGER  DEFAULT null;

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `id_magFisico` INTEGER  DEFAULT null;

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `segnoMov` INTEGER  DEFAULT null;


ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `id_rigaDocumentoMov` INTEGER;


# ---------------------------------------------------------------------- #
# Alter table "RIGA_DOCUMENTO"                                           #
# ---------------------------------------------------------------------- #


ALTER TABLE `RIGA_DOCUMENTO` ADD CONSTRAINT `CAUSALE_MAGAZZINO_RIGA_DOCUMENTO` 
    FOREIGN KEY (`id_causaleMagazzino`) REFERENCES `CAUSALE_MAGAZZINO` (`id_causaleMagazzino`);

ALTER TABLE `RIGA_DOCUMENTO` ADD CONSTRAINT `CLIFOR_RIGA_DOCUMENTO` 
    FOREIGN KEY (`id_clifor`) REFERENCES `CLIFOR` (`id_clifor`);

ALTER TABLE `RIGA_DOCUMENTO` ADD CONSTRAINT `MAG_FISICO_RIGA_DOCUMENTO` 
    FOREIGN KEY (`id_magFisico`) REFERENCES `MAG_FISICO` (`id_magFisico`);


ALTER TABLE `RIGA_DOCUMENTO` ADD CONSTRAINT `RIGA_DOCUMENTO_RIGA_DOCUMENTO_MOV` 
    FOREIGN KEY (`id_rigaDocumentoMov`) REFERENCES `RIGA_DOCUMENTO` (`id_rigaDocumento`);
	
	
	##rigadocprelevata
	
# ---------------------------------------------------------------------- #
# Drop table "DISPONIBILITA"                                             #
# ---------------------------------------------------------------------- #

# Remove autoinc for PK drop #

ALTER TABLE `DISPONIBILITA` MODIFY `id_disponibilita` INTEGER NOT NULL;

# Drop constraints #

ALTER TABLE `DISPONIBILITA` DROP PRIMARY KEY;

DROP TABLE `DISPONIBILITA`;



# ---------------------------------------------------------------------- #
# Alter table "RIGA_DOCUMENTO"                                           #
# ---------------------------------------------------------------------- #

ALTER TABLE `RIGA_DOCUMENTO` ADD COLUMN `id_rigaDocumentoPrelevata` INTEGER;

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

ALTER TABLE `CODA_MESSAGGI` CHANGE `messaggio` `testoMessaggio` TEXT;

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

ALTER TABLE `TEMPLATE_MSG` CHANGE `messaggio` `testoMessaggio` TEXT;



ALTER TABLE `RIGA_DOCUMENTO` ADD CONSTRAINT `RIGA_DOCUMENTO_RIGA_DOCUMENTO_PRELEVATA` 
    FOREIGN KEY (`id_rigaDocumentoPrelevata`) REFERENCES `RIGA_DOCUMENTO` (`id_rigaDocumento`);

# ---------------------------------------------------------------------- #
# Modify table "DOCUMENTO"                                               #
# ---------------------------------------------------------------------- #

ALTER TABLE `DOCUMENTO` ADD COLUMN `percAgente` DOUBLE;

ALTER TABLE `DOCUMENTO` ADD COLUMN `percRespCommerciale` DOUBLE;


# ---------------------------------------------------------------------- #
# Modify table "TIPO_DOCUMENTO"                                          #
# ---------------------------------------------------------------------- #

ALTER TABLE `TIPO_DOCUMENTO` ADD COLUMN `notaConfermaOrdine` VARCHAR(1000);