-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update from hms-dbmi-cellenics/api@e750868
- Loading branch information
hms-dbmi-cellenics
committed
Sep 20, 2024
1 parent
72c4b51
commit a4f8e88
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
migrations/sql/20240919171424_rename_last_status_seurat.js
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,33 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = async (knex) => { | ||
// We're using `pipeline_type::text = 'obj2s'` to cast the enum to a text type. | ||
// This avoids the potential issue of "unsafe use of new value" caused by enum strictness. | ||
await knex('experiment_execution') | ||
.where(knex.raw("pipeline_type::text = 'obj2s'")) // Cast enum to text for comparison | ||
.update({ | ||
// Use jsonb_set to add the new `obj2s` key to last_status_response with the value from `seurat`. | ||
// Then, remove the old `seurat` key from last_status_response. | ||
last_status_response: knex.raw( | ||
'jsonb_set(last_status_response::jsonb, \'{obj2s}\', last_status_response::jsonb->\'seurat\', true) - \'seurat\'', | ||
), | ||
}); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = async (knex) => { | ||
// Revert the same logic in the down migration: cast the enum to text to avoid issues. | ||
await knex('experiment_execution') | ||
.where(knex.raw("pipeline_type::text = 'obj2s'")) // Again, cast enum to text for comparison | ||
.update({ | ||
// Revert the key change by adding `seurat` back and removing `obj2s`. | ||
last_status_response: knex.raw( | ||
'jsonb_set(last_status_response::jsonb, \'{seurat}\', last_status_response::jsonb->\'obj2s\', true) - \'obj2s\'', | ||
), | ||
}); | ||
}; |