/**
 * @author dbu
 * @date 23/08/22
 * @version 1.0.0
 * @project SIEau
 * @table codes_sandre
 */

# --- !Ups
insert into codes_sandre (champ, code, libelle, datecreation)
    (select 'CAMPAGNES.STATUT', 1, 'En prévision', now()
     from codes_sandre
     where not exists(select champ, code from codes_sandre where champ = 'CAMPAGNES.STATUT' and code = 1)
     limit 1);

insert into codes_sandre (champ, code, libelle, datecreation)
    (select 'CAMPAGNES.STATUT', 2, 'En cours', now()
     from codes_sandre
     where not exists(select champ, code from codes_sandre where champ = 'CAMPAGNES.STATUT' and code = 2)
         limit 1);

insert into codes_sandre (champ, code, libelle, datecreation)
    (select 'CAMPAGNES.STATUT', 3, 'Finalisées', now()
     from codes_sandre
     where not exists(select champ, code from codes_sandre where champ = 'CAMPAGNES.STATUT' and code = 3)
         limit 1);

insert into codes_sandre (champ, code, libelle, datecreation)
    (select 'CAMPAGNES.STATUT', 4, 'Archivé', now()
     from codes_sandre
     where not exists(select champ, code from codes_sandre where champ = 'CAMPAGNES.STATUT' and code = 4)
         limit 1);

# --- !Downs

