Included user-information in employee Model.
This commit is contained in:
@@ -18,11 +18,15 @@ export default class Employees extends BaseSchema {
|
||||
table.string('email')
|
||||
table.string('phone')
|
||||
table.string('mobile')
|
||||
table.string('username').unique()
|
||||
table.string('password')
|
||||
table.string('role')
|
||||
.defaultTo('employee')
|
||||
.notNullable()
|
||||
table.boolean('is_active')
|
||||
.defaultTo(false)
|
||||
.notNullable()
|
||||
table.decimal('contract_hours', 2, 2)
|
||||
table
|
||||
.integer('user_id')
|
||||
.unsigned()
|
||||
.references('users.id')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Users extends BaseSchema {
|
||||
protected tableName = 'users'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
|
||||
/**
|
||||
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||
*/
|
||||
table.timestamp('created_at', { useTz: true })
|
||||
table.timestamp('updated_at', { useTz: true })
|
||||
table.string('username').notNullable().unique()
|
||||
table.string('email').notNullable().unique()
|
||||
table.string('password').notNullable()
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import Hash from '@ioc:Adonis/Core/Hash'
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
import User from 'App/Models/User'
|
||||
|
||||
export default class Users extends BaseSchema {
|
||||
protected tableName = 'users'
|
||||
|
||||
public async up () {
|
||||
this.schema.alterTable(this.tableName, (table) => {
|
||||
table.boolean('is_active').defaultTo(false)
|
||||
table.string('role')
|
||||
.defaultTo('employee')
|
||||
.notNullable()
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.alterTable(this.tableName, (table) => {
|
||||
table.dropColumn('is_active')
|
||||
table.dropColumn('role')
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ export default class ApiTokens extends BaseSchema {
|
||||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
|
||||
table.integer('user_id').unsigned().references('id').inTable('employee').onDelete('CASCADE')
|
||||
table.string('name').notNullable()
|
||||
table.string('type').notNullable()
|
||||
table.string('token', 64).notNullable().unique()
|
||||
|
||||
Reference in New Issue
Block a user