Skip to content

Commit

Permalink
Create migration, model etc for licence_versions
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-3486

Whilst working on the unit tests for the enhancement in this PR #443 it was found that we would need the migrations, model, helper and unit tests for table `licence_versions`.

These will be created in this PR.
  • Loading branch information
Jozzey committed Oct 9, 2023
1 parent 27d7547 commit d2914eb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions db/migrations/20231009155523_create-water-licence-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict'

const tableName = 'licence_versions'

exports.up = function (knex) {
return knex
.schema
.withSchema('water')
.createTable(tableName, (table) => {
// Primary Key
table.uuid('licence_version_id').primary().defaultTo(knex.raw('gen_random_uuid()'))

// Data
table.uuid('licence_id').notNullable()
table.integer('issue').notNullable()
table.integer('increment').notNullable()
table.string('status').notNullable()
table.date('start_date').notNullable()
table.date('end_date')
table.string('external_id').notNullable()
table.boolean('is_test').notNullable().defaultTo(false)

// Legacy timestamps
table.timestamp('date_created', { useTz: false }).notNullable()
table.timestamp('date_updated', { useTz: false }).notNullable()
})
}

exports.down = function (knex) {
return knex
.schema
.withSchema('water')
.dropTableIfExists(tableName)
}

0 comments on commit d2914eb

Please sign in to comment.