Skip to content

Commit

Permalink
feat: alter compliance_checks table to support checklists
Browse files Browse the repository at this point in the history
Related #163
  • Loading branch information
UlisesGascon committed Dec 24, 2024
1 parent c084c7a commit ac7dad7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/database/migrations/1735041299955_alter_compliance_checks.js
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')
})
}

0 comments on commit ac7dad7

Please sign in to comment.