Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create idm migrations for authentication plugin #384

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions db/migrations/20230823150507_create-idm-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

exports.up = function (knex) {
return knex.raw(`
CREATE SCHEMA IF NOT EXISTS "idm";
`)
}

exports.down = function (knex) {
return knex.raw(`
DROP SCHEMA IF EXISTS "idm";
`)
}
39 changes: 39 additions & 0 deletions db/migrations/20230823150600_create-idm-users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict'

const tableName = 'users'

exports.up = function (knex) {
return knex
.schema
.withSchema('idm')
.createTable(tableName, (table) => {
// Primary Key
table.integer('user_id').primary().notNullable()

// Data
table.string('user_name').notNullable()
table.string('password').notNullable()
table.jsonb('user_data')
table.string('reset_guid')
table.bigint('reset_required')

table.timestamp('last_login')
table.bigint('bad_logins')
table.string('application')
table.jsonb('role')
table.string('external_id')
table.timestamp('reset_guid_date_created')
table.boolean('enabled').notNullable().defaultTo(true)

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

exports.down = function (knex) {
return knex
.schema
.withSchema('idm')
.dropTableIfExists(tableName)
}
28 changes: 28 additions & 0 deletions db/migrations/20230824092452_create-idm-group-roles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

const tableName = 'group_roles'

exports.up = function (knex) {
return knex
.schema
.withSchema('idm')
.createTable(tableName, (table) => {
// Primary Key
table.string('user_id').primary().notNullable()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary key on this table should be group_role_id


// Data
table.string('group_id').notNullable()
table.string('role_id').notNullable()

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

exports.down = function (knex) {
return knex
.schema
.withSchema('idm')
.dropTableIfExists(tableName)
}
29 changes: 29 additions & 0 deletions db/migrations/20230824092657_create-idm-groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

const tableName = 'groups'

exports.up = function (knex) {
return knex
.schema
.withSchema('idm')
.createTable(tableName, (table) => {
// Primary Key
table.string('group_id').primary().notNullable()

// Data
table.string('application')
table.string('group').notNullable()
table.string('description').notNullable()

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

exports.down = function (knex) {
return knex
.schema
.withSchema('idm')
.dropTableIfExists(tableName)
}
29 changes: 29 additions & 0 deletions db/migrations/20230824092939_create-idm-roles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

const tableName = 'roles'

exports.up = function (knex) {
return knex
.schema
.withSchema('idm')
.createTable(tableName, (table) => {
// Primary Key
table.integer('role_id').primary()

// Data
table.string('application')
table.string('role').notNullable()
table.string('description').notNullable()

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

exports.down = function (knex) {
return knex
.schema
.withSchema('idm')
.dropTableIfExists(tableName)
}
28 changes: 28 additions & 0 deletions db/migrations/20230824093122_create-idm-user-groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

const tableName = 'user_groups'

exports.up = function (knex) {
return knex
.schema
.withSchema('idm')
.createTable(tableName, (table) => {
// Primary Key
table.string('user_group_id').primary().notNullable()

// Data
table.integer('user_id').notNullable()
table.string('group_id').notNullable()

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

exports.down = function (knex) {
return knex
.schema
.withSchema('idm')
.dropTableIfExists(tableName)
}
28 changes: 28 additions & 0 deletions db/migrations/20230824142221_create-idm-user-roles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

const tableName = 'user_roles'

exports.up = function (knex) {
return knex
.schema
.withSchema('idm')
.createTable(tableName, (table) => {
// Primary Key
table.string('user_role_id').primary().notNullable()

// Data
table.integer('user_id').notNullable()
table.string('role_id').notNullable()

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

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