-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SPI ETL: Map SPI Species Codes to ITIS TSNs (#1362)
* add species map * linter * cleanup and comments
- Loading branch information
1 parent
5b85c86
commit 2af93d3
Showing
12 changed files
with
21,128 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
database/src/migrations/20240906142100_spi_species_table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Knex } from 'knex'; | ||
|
||
/** | ||
* Add columns to the following tables for the SPI data migration: | ||
* - project | ||
* - survey | ||
* - study species | ||
* @export | ||
* @param {Knex} knex | ||
* @return {*} {Promise<void>} | ||
*/ | ||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw(`--sql | ||
SET SEARCH_PATH=public; | ||
---------------------------------------------------------------------------------------- | ||
-- Table that the SPI ETL scripts insert into, for mapping SPI species codes to ITIS TSNs | ||
---------------------------------------------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS public.migrate_spi_species ( | ||
id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), | ||
spi_species_id INTEGER NOT NULL, | ||
spi_species_code VARCHAR(128), | ||
spi_scientific_name VARCHAR(128), | ||
spi_rank VARCHAR(24), | ||
itis_tsn VARCHAR(16), | ||
itis_scientific_name VARCHAR(128), | ||
itis_rank VARCHAR(24), | ||
CONSTRAINT itis_tsn_uk UNIQUE (itis_tsn), | ||
CONSTRAINT spi_species_id_uk UNIQUE (spi_species_id) | ||
); | ||
`); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.raw(``); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ coverage | |
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
yarn-error.log* |
Oops, something went wrong.