-
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.
update null sign id values to direct sighting
- Loading branch information
1 parent
430d007
commit 4793c8f
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
database/src/migrations/20240923161500_update_obs_sign_id.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,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(``); | ||
} |