diff --git a/migrations/20240612130105_agrandir-champs-texte.js b/migrations/20240612130105_agrandir-champs-texte.js new file mode 100644 index 00000000..f657ced7 --- /dev/null +++ b/migrations/20240612130105_agrandir-champs-texte.js @@ -0,0 +1,19 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +export function up(knex) { + return knex.schema.alterTable('dossier', (table) => { + table.text('espèces_protégées_concernées').alter(); + }); +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +export function down(knex) { + return knex.schema.alterTable('dossier', (table) => { + table.string('espèces_protégées_concernées').alter() + }); +}; diff --git "a/outils/sync-d\303\251marches-simplifi\303\251es.js" "b/outils/sync-d\303\251marches-simplifi\303\251es.js" index 7c1f70de..579211ca 100644 --- "a/outils/sync-d\303\251marches-simplifi\303\251es.js" +++ "b/outils/sync-d\303\251marches-simplifi\303\251es.js" @@ -83,8 +83,11 @@ const dossiers = démarche.dossiers.nodes.map(({ let régions; if(champCommunes){ - communes = champCommunes.rows.map(c => c.champs[0].commune) - départements = [... new Set(champCommunes.rows.map(c => c.champs[0].departement.code))] + communes = champCommunes.rows.map(c => c.champs[0].commune).filter(x => !!x) + + if(Array.isArray(communes) && communes.length >= 1){ + départements = [... new Set(champCommunes.rows.map(c => c.champs[0].departement.code))] + } } else{ if(champDépartements){