Skip to content

Commit

Permalink
update null sign id values to direct sighting
Browse files Browse the repository at this point in the history
  • Loading branch information
mauberti-bc committed Sep 23, 2024
1 parent 430d007 commit 4793c8f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions database/src/migrations/20240923161500_update_obs_sign_id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Knex } from 'knex';

/**
* Bug fix:
* Observation subcount sign id cannot be null, so this updates observation subcount records to change null values to 'direct sighting'.
*
* @export
* @param {Knex} knex
* @return {*} {Promise<void>}
*/
export async function up(knex: Knex): Promise<void> {
await knex.raw(`--sql
SET SEARCH_PATH=biohub;
UPDATE observation_subcount
SET observation_subcount_sign_id = (SELECT observation_subcount_sign_id FROM observation_subcount_sign WHERE lower(name) = 'direct sighting')
WHERE observation_subcount_sign_id IS NULL;
`);
}

export async function down(knex: Knex): Promise<void> {
await knex.raw(``);
}

0 comments on commit 4793c8f

Please sign in to comment.