From 368d1160eb5f57ae63db6f98fbc2f8a752af4cb7 Mon Sep 17 00:00:00 2001 From: Edvaldo Szymonek Date: Tue, 5 May 2026 16:42:02 -0300 Subject: [PATCH] =?UTF-8?q?remove=20migra=C3=A7=C3=A3o=20do=20nome=20cient?= =?UTF-8?q?=C3=ADfico=20at=C3=A9=20aprova=C3=A7=C3=A3o=20para=20execu?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70000_fix-nome-cientifico-inconsistente.ts | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 src/database/migration/20260404170000_fix-nome-cientifico-inconsistente.ts diff --git a/src/database/migration/20260404170000_fix-nome-cientifico-inconsistente.ts b/src/database/migration/20260404170000_fix-nome-cientifico-inconsistente.ts deleted file mode 100644 index bac7528..0000000 --- a/src/database/migration/20260404170000_fix-nome-cientifico-inconsistente.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Knex } from 'knex' - -export async function run(knex: Knex): Promise { - await knex.transaction(async trx => { - // Atualiza tombos que possuem genero e especie - await trx.raw(` - UPDATE tombos - SET nome_cientifico = CONCAT(g.nome, ' ', e.nome) - FROM generos g, especies e - WHERE tombos.genero_id = g.id - AND tombos.especie_id = e.id - AND ( - tombos.nome_cientifico IS DISTINCT FROM CONCAT(g.nome, ' ', e.nome) - OR e.genero_id IS DISTINCT FROM tombos.genero_id - ) - `) - - // Atualiza tombos que possuem apenas genero (sem especie) - await trx.raw(` - UPDATE tombos - SET nome_cientifico = g.nome - FROM generos g - WHERE tombos.genero_id = g.id - AND tombos.especie_id IS NULL - AND tombos.nome_cientifico IS DISTINCT FROM g.nome - `) - }) -}