Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/database/migration/20260408200000_cria_view_splinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function run(knex: Knex): Promise<void> {
// 2. Cria a view do splinker com todos os campos do map.dat
await knex.raw(`DROP VIEW IF EXISTS vw_splinker`)
await knex.raw(`
CREATE VIEW vw_splinker AS
CREATE OR REPLACE VIEW vw_splinker AS
SELECT
'Plantae' AS "Kingdom",
'' AS "Phylum",
Expand All @@ -44,7 +44,7 @@ export async function run(knex: Knex): Promise<void> {
COALESCE(t.data_coleta_dia::text, '') AS "DayCollected",
COALESCE(t.data_coleta_mes::text, '') AS "MonthCollected",
COALESCE(t.data_coleta_ano::text, '') AS "YearCollected",
COALESCE(col.nome, '') AS "Collector",
COALESCE((col.nome || cc.complementares), '') AS "Collector",
COALESCE(t.numero_coleta::text, '') AS "CollectorNumber",
'' AS "Continent",
COALESCE(p.nome, '') AS "Country",
Expand Down Expand Up @@ -85,6 +85,7 @@ export async function run(knex: Knex): Promise<void> {
LEFT JOIN especies e ON t.especie_id = e.id
LEFT JOIN autores a ON e.autor_id = a.id
LEFT JOIN coletores col ON t.coletor_id = col.id
LEFT JOIN coletores_complementares cc ON cc.hcf = t.hcf
LEFT JOIN tipos tp ON t.tipo_id = tp.id
`)
}
Loading