-- MàJ de la version en BDD
UPDATE om_version SET om_version = '5.19.0' WHERE exists(SELECT 1 FROM om_version) = true;
INSERT INTO om_version
SELECT ('5.19.0') WHERE exists(SELECT 1 FROM om_version) = false;


--
-- BEGIN / [#10210] Téléchargement des pièces d'un DI 
--

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'ADMINISTRATEUR TECHNIQUE ET FONCTIONNEL')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'ADMINISTRATEUR TECHNIQUE ET FONCTIONNEL')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'ADMINISTRATEUR GENERAL')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'ADMINISTRATEUR GENERAL')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'ASSISTANTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT COMMUNE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'INSTRUCTEUR POLYVALENT')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'VISUALISATION DA et DI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET ET SUIVI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'GUICHET UNIQUE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'CHEF DE SERVICE CONTENTIEUX')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'TECHNICIEN')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'JURISTE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_instruction',
(SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_instruction'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_travail',
(SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_travail'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_dossier_final',
(SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'RESPONSABLE DIVISION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ ÉTENDU')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ ÉTENDU')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ INTERNE')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ INTERNE')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ DI')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ DI')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS')
);

INSERT INTO om_droit (om_droit, libelle, om_profil)
SELECT nextval('om_droit_seq'), 'document_numerise_telechargement',
(SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION CONSULTATION')
WHERE NOT EXISTS (
    SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_telechargement'
    AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION CONSULTATION')
);

DELETE FROM om_droit IF WHERE om_droit = (SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final' AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION CONSULTATION'));
DELETE FROM om_droit IF WHERE om_droit = (SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final' AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION RECOURS'));
DELETE FROM om_droit IF WHERE om_droit = (SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final' AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'DIRECTION INFRACTION'));
DELETE FROM om_droit IF WHERE om_droit = (SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final' AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ DI'));
DELETE FROM om_droit IF WHERE om_droit = (SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final' AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ INTERNE'));
DELETE FROM om_droit IF WHERE om_droit = (SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final' AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ ÉTENDU'));
DELETE FROM om_droit IF WHERE om_droit = (SELECT om_droit FROM om_droit WHERE libelle = 'document_numerise_dossier_final' AND om_profil = (SELECT om_profil FROM om_profil WHERE libelle = 'SERVICE CONSULTÉ'));

--
-- END / [#10210] Téléchargement des pièces d'un DI 
--


--
-- BEGIN / [#10221]-Certains champs de type boolean ne sont pas en default False dans la BDD 
--

ALTER TABLE architecte ALTER COLUMN frequent SET DEFAULT false;


ALTER TABLE cerfa ALTER COLUMN am_lotiss SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_autre_div SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_camping SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_caravane SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_carav_duree SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_statio SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_statio_cont SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_affou_exhau SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_affou_exhau_sup SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_affou_prof SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_exhau_haut SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_abat SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_prot_plu SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_prot_muni SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_mobil_voyage SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_aire_voyage SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_rememb_afu SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_parc_resid_loi SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_sport_moto SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_sport_attrac SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_sport_golf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_mob_art SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_modif_voie_esp SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_plant_voie_esp SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_chem_ouv_esp SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_agri_peche SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_crea_voie SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_modif_voie_exist SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_crea_esp_sauv SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_crea_esp_class SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_projet_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_terr_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_tranche_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_max_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_max_shon SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_cstr_cos SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_cstr_plan SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_cstr_vente SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_fin_diff SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_consign SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_gar_achev SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_lot_vente_ant SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_empl_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_tente_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_carav_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_mobil_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_pers_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_empl_hll_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_hll_shon SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_periode_exploit SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_exist_agrand SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_exist_date SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_exist_num SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_exist_nb_avant SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_exist_nb_apres SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_bois SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_parc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_align SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_ess SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_age SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_dens SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_qual SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_trait SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_coupe_autr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_archi_recours SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_cstr_nouv SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_cstr_exist SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_cloture SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_elec_tension SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_div_terr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_projet_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_anx_pisc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_anx_gara SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_anx_veran SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_anx_abri SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_anx_autr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_anx_autr_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_tot_log_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_tot_ind_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_tot_coll_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_mais_piece_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_mais_niv_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_fin_lls_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_fin_aa_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_fin_ptz_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_fin_autr_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_fin_autr_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_mais_contrat_ind SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_uti_pers SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_uti_vente SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_uti_loc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_uti_princ SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_uti_secon SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_agees SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_etud SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_tourism SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_hot_soc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_soc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_hand SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_autr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_resid_autr_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_foyer_chamb_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_log_1p_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_log_2p_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_log_3p_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_log_4p_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_log_5p_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_log_6p_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_bat_niv_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_trx_exten SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_trx_surelev SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_trx_nivsup SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_demont_periode SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_sp_transport SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_sp_enseign SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_sp_act_soc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_sp_ouvr_spe SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_sp_sante SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_sp_culture SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_statio_avt_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_statio_apr_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_statio_adr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_statio_place_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_statio_tot_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_statio_tot_shob SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_statio_comm_cin_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN dm_constr_dates SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN dm_total SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN dm_partiel SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN dm_projet_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN dm_tot_log_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_surf_tot SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_surf_suppr_mod SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_ext_pret SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_ext_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_surf_tax_exist_cons SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_log_exist_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_trx_presc_ppr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_monu_hist SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN tax_comm_nb SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN vsd_surf_planch_smd SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN vsd_unit_fonc_sup SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN vsd_unit_fonc_constr_sup SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN vsd_val_terr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN vsd_const_sxist_non_dem_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN vsd_rescr_fisc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN pld_val_terr SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN pld_const_exist_dem SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN pld_const_exist_dem_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN code_cnil SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_juri_titul SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_juri_lot SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_juri_zac SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_juri_afu SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_juri_pup SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_juri_oin SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_juri_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_div_surf_etab SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN terr_div_surf_av_div SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_date SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_tot_trav SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_tranche_trav SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_tranche_trav_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_nb_log SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_nb_log_indiv SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_nb_log_coll SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_nb_log_lls SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_nb_log_aa SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_nb_log_ptz SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN doc_nb_log_autre SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_date SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_date_chgmt_dest SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_tot_trav SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_tranche_trav SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_tranche_trav_desc SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_surf SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_nb_log SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_nb_log_indiv SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_nb_log_coll SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_nb_log_lls SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_nb_log_aa SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_nb_log_ptz SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN daact_nb_log_autre SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN am_div_mun SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN co_perf_energ SET DEFAULT false;
ALTER TABLE cerfa ALTER COLUMN architecte SET DEFAULT false; 

ALTER TABLE commission ALTER COLUMN om_final_commission_ordre_jour SET DEFAULT false;
ALTER TABLE commission ALTER COLUMN om_final_commission_compte_rendu SET DEFAULT false;

ALTER TABLE consultation ALTER COLUMN lu SET DEFAULT false;
ALTER TABLE consultation ALTER COLUMN om_final_consultation SET DEFAULT false;

ALTER TABLE demande_type ALTER COLUMN qualification SET DEFAULT false;

ALTER TABLE demandeur ALTER COLUMN notification SET DEFAULT false;
ALTER TABLE demandeur ALTER COLUMN frequent SET DEFAULT false;

ALTER TABLE donnees_techniques ALTER COLUMN am_lotiss SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_autre_div SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_camping SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_caravane SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_statio SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_affou_exhau SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_coupe_abat SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_prot_plu SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_prot_muni SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_mobil_voyage SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_aire_voyage SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_rememb_afu SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_parc_resid_loi SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_sport_moto SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_sport_attrac SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_sport_golf SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_mob_art SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_modif_voie_esp SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_plant_voie_esp SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_chem_ouv_esp SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_agri_peche SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_crea_voie SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_modif_voie_exist SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_crea_esp_sauv SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_crea_esp_class SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_lot_cstr_cos SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_lot_cstr_plan SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_lot_cstr_vente SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_lot_fin_diff SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_lot_consign SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_lot_gar_achev SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_lot_vente_ant SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_exist_agrand SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_coupe_bois SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_coupe_parc SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_coupe_align SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_archi_recours SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_cstr_nouv SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_cstr_exist SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_cloture SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_div_terr SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_anx_pisc SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_anx_gara SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_anx_veran SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_anx_abri SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_anx_autr SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_mais_contrat_ind SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_uti_pers SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_uti_vente SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_uti_loc SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_uti_princ SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_uti_secon SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_resid_agees SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_resid_etud SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_resid_tourism SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_resid_hot_soc SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_resid_soc SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_resid_hand SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_resid_autr SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_trx_exten SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_trx_surelev SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_trx_nivsup SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_sp_transport SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_sp_enseign SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_sp_act_soc SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_sp_ouvr_spe SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_sp_sante SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_sp_culture SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN dm_total SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN dm_partiel SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN tax_trx_presc_ppr SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN tax_monu_hist SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN vsd_surf_planch_smd SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN pld_const_exist_dem SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN code_cnil SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN doc_tot_trav SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN doc_tranche_trav SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN daact_tot_trav SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN daact_tranche_trav SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN am_div_mun SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_ouvr_elec SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN co_ouvr_infra SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN avap_co_elt_pro SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN avap_nouv_haut_surf SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN ctx_infraction SET DEFAULT false;
ALTER TABLE donnees_techniques ALTER COLUMN ctx_regularisable SET DEFAULT false; 

ALTER TABLE dossier ALTER COLUMN erp SET DEFAULT false;
ALTER TABLE dossier ALTER COLUMN enjeu_erp SET DEFAULT false;
ALTER TABLE dossier ALTER COLUMN enjeu_urba SET DEFAULT false;
ALTER TABLE dossier ALTER COLUMN a_qualifier SET DEFAULT false;
ALTER TABLE dossier ALTER COLUMN interface_referentiel_erp SET DEFAULT false;

ALTER TABLE dossier_autorisation ALTER COLUMN erp_ouvert SET DEFAULT false;
ALTER TABLE dossier_autorisation ALTER COLUMN erp_arrete_decision SET DEFAULT false;

ALTER TABLE dossier_geolocalisation ALTER COLUMN etat_verif_parcelle SET DEFAULT false;
ALTER TABLE dossier_geolocalisation ALTER COLUMN etat_calcul_emprise SET DEFAULT false;
ALTER TABLE dossier_geolocalisation ALTER COLUMN etat_dessin_emprise SET DEFAULT false;
ALTER TABLE dossier_geolocalisation ALTER COLUMN etat_calcul_centroide SET DEFAULT false;
ALTER TABLE dossier_geolocalisation ALTER COLUMN etat_recup_contrainte SET DEFAULT false;

ALTER TABLE instruction ALTER COLUMN om_final_instruction SET DEFAULT false;
ALTER TABLE instruction ALTER COLUMN flag_edition_integrale SET DEFAULT false;

ALTER TABLE lien_demande_demandeur ALTER COLUMN petitionnaire_principal SET DEFAULT false;

ALTER TABLE lien_dossier_autorisation_demandeur ALTER COLUMN petitionnaire_principal SET DEFAULT false;

ALTER TABLE lien_dossier_demandeur ALTER COLUMN petitionnaire_principal SET DEFAULT false;

ALTER TABLE lien_lot_demandeur ALTER COLUMN petitionnaire_principal SET DEFAULT false;

ALTER TABLE om_etat ALTER COLUMN actif SET DEFAULT false;

ALTER TABLE om_lettretype ALTER COLUMN actif SET DEFAULT false;

ALTER TABLE om_logo ALTER COLUMN actif SET DEFAULT false;

ALTER TABLE om_sig_extent ALTER COLUMN valide SET DEFAULT false;

ALTER TABLE om_sig_map ALTER COLUMN actif SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN fond_osm SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN fond_bing SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN fond_sat SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN layer_info SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN util_idx SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN util_reqmo SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN util_recherche SET DEFAULT false;
ALTER TABLE om_sig_map ALTER COLUMN restrict_extent SET DEFAULT false;

ALTER TABLE om_sig_map_comp ALTER COLUMN actif SET DEFAULT false;
ALTER TABLE om_sig_map_comp ALTER COLUMN comp_maj SET DEFAULT false;

ALTER TABLE om_sig_map_flux ALTER COLUMN visibility SET DEFAULT false;
ALTER TABLE om_sig_map_flux ALTER COLUMN panier SET DEFAULT false;
ALTER TABLE om_sig_map_flux ALTER COLUMN baselayer SET DEFAULT false;
ALTER TABLE om_sig_map_flux ALTER COLUMN singletile SET DEFAULT false;

ALTER TABLE om_sousetat ALTER COLUMN actif SET DEFAULT false;

ALTER TABLE rapport_instruction ALTER COLUMN om_final_rapport_instruction SET DEFAULT false;

ALTER TABLE service ALTER COLUMN consultation_papier SET DEFAULT false;
ALTER TABLE service ALTER COLUMN notification_email SET DEFAULT false;

ALTER TABLE signataire_arrete ALTER COLUMN defaut SET DEFAULT false;

--
-- END / [#10221]-Certains champs de type boolean ne sont pas en default False dans la BDD 
--