Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix: Update Null Values for Sign ID in Observation Subcounts #1374

Merged
merged 3 commits into from
Sep 24, 2024
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
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(`
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(``);
}