Skip to content

Commit

Permalink
Merge pull request #36 from secure-dashboards/feat/add-compliance-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
UlisesGascon authored Dec 6, 2024
2 parents df1a703 + 5378abc commit fb7627e
Show file tree
Hide file tree
Showing 3 changed files with 1,480 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/database/migrations/1733494222119_add_compliance_checks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const statusLevels = ['n/a', 'deferrable', 'expected', 'recommended']

exports.up = async (knex) => {
await knex.schema.createTable('compliance_checks', (table) => {
table.increments('id').primary() // Primary key
table.string('title').notNullable()
table.text('description').notNullable()
table.string('section_number').notNullable()
table.string('section_name').notNullable()
table.string('code_name').unique().notNullable()
table.string('priority_group').notNullable()
table.boolean('is_c_scrm').notNullable().defaultTo(false)
table.enum('level_incubating_status', statusLevels).notNullable()
table.enum('level_active_status', statusLevels).notNullable()
table.enum('level_retiring_status', statusLevels).notNullable()
table.string('mitre_url')
table.string('mitre_description')
table.string('how_to_url')
table.text('how_to_description')
table.string('sources_url')
table.text('sources_description')
table.enum('implementation_status', ['pending', 'completed']).notNullable().defaultTo('pending')
table.enum('implementation_type', ['manual', 'computed'])
table.text('implementation_details_reference')
table.text('details_url').notNullable()

// Timestamps
table.timestamp('created_at').defaultTo(knex.fn.now()).notNullable()
table.timestamp('updated_at').defaultTo(knex.fn.now()).notNullable()
})

// Add trigger to automatically update the 'updated_at' column
await knex.raw(`
CREATE TRIGGER set_updated_at_compliance_checks
BEFORE UPDATE ON compliance_checks
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
`)
}

exports.down = async (knex) => {
// Drop trigger
await knex.raw('DROP TRIGGER IF EXISTS set_updated_at_compliance_checks ON compliance_checks;')
// Drop table
await knex.schema.dropTableIfExists('compliance_checks')
}
Loading

0 comments on commit fb7627e

Please sign in to comment.