diff --git a/db/migrations/20231009155523_create-water-licence-versions.js b/db/migrations/20231009155523_create-water-licence-versions.js new file mode 100644 index 0000000000..00699ff1e4 --- /dev/null +++ b/db/migrations/20231009155523_create-water-licence-versions.js @@ -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) +}