-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: alter
compliance_checks
table to support checklists
Related #163
- Loading branch information
1 parent
c084c7a
commit ac7dad7
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/database/migrations/1735041299955_alter_compliance_checks.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,29 @@ | ||
const statusLevels = ['n/a', 'deferrable', 'expected', 'recommended'] | ||
|
||
exports.up = async (knex) => { | ||
await knex.schema.alterTable('compliance_checks', (table) => { | ||
// Drop old fields | ||
table.dropColumn('level_incubating_status') | ||
table.dropColumn('level_active_status') | ||
table.dropColumn('level_retiring_status') | ||
|
||
// Rename fields | ||
table.renameColumn('priority_group', 'default_priority_group') | ||
table.renameColumn('section_number', 'default_section_number') | ||
table.renameColumn('section_name', 'default_section_name') | ||
}) | ||
} | ||
|
||
exports.down = async (knex) => { | ||
await knex.schema.alterTable('compliance_checks', (table) => { | ||
// IMPORTANT: Re-add dropped fields but without the original values and nullable. | ||
table.enum('level_incubating_status', statusLevels).nullable() | ||
table.enum('level_active_status', statusLevels).nullable() | ||
table.enum('level_retiring_status', statusLevels).nullable() | ||
|
||
// Rename fields back | ||
table.renameColumn('default_priority_group', 'priority_group') | ||
table.renameColumn('default_section_number', 'section_number') | ||
table.renameColumn('default_section_name', 'section_name') | ||
}) | ||
} |