/**
 * @author tpasquet via pminot
 * @date 25/10/21
 * @version 1.0.0
 * @project SIEau
 * @table enquetes_reponses_doc pgsse_dangers_doc pgsse_dangers inst_visites
 */

# --- !Ups
ALTER TABLE inst_visites DROP COLUMN IF EXISTS pgsse;
ALTER TABLE inst_visites DROP COLUMN IF EXISTS idEnquete;
ALTER TABLE inst_visites ADD COLUMN idEnquete BIGINT;
ALTER TABLE enquetes_reponses DROP COLUMN IF EXISTS idParagraphe;
ALTER TABLE enquetes_reponses ADD COLUMN idParagraphe BIGINT;
ALTER TABLE enquetes_reponses DROP COLUMN IF EXISTS codevisite;
ALTER TABLE enquetes_reponses ADD COLUMN codevisite BIGINT;
ALTER TABLE enquetes_reponses DROP COLUMN IF EXISTS codecampagne;
ALTER TABLE enquetes_reponses ADD COLUMN codecampagne BIGINT;
DROP TABLE IF EXISTS enquetes_reponses_doc;
CREATE TABLE IF NOT EXISTS enquetes_reponses_doc (
                                                     idEnquete BIGINT,
                                                     codeInstallation BIGINT,
                                                     idQuestionLie BIGINT,
                                                     nomDocument VARCHAR ( 255 ),
    description VARCHAR ( 255 ),
    codevisite BIGINT,
    codecampagne BIGINT
    );
DROP TABLE IF EXISTS pgsse_dangers_doc;
CREATE TABLE IF NOT EXISTS pgsse_dangers_doc (
                                                 idEnquete BIGINT,
                                                 typeSite BIGINT,
                                                 codeSite BIGINT,
                                                 idDanger BIGINT,
                                                 nomDocument VARCHAR ( 255 ),
    description VARCHAR ( 255 ),
    codevisite BIGINT,
    codecampagne BIGINT
    );
DROP TABLE IF EXISTS pgsse_dangers;
CREATE TABLE IF NOT EXISTS pgsse_dangers (
                                             idDanger BIGINT,
                                             idEnquete BIGINT,
                                             typeSite BIGINT,
                                             codeSite BIGINT,
                                             typeLexique VARCHAR ( 50 ),
    situationDangereuse BIGINT,
    commentaire VARCHAR ( 255 ),
    codevisite BIGINT,
    codecampagne BIGINT,
    idquestionLie BIGINT,
    idparagraphlie BIGINT
    );

# --- !Downs