Files
duty-schedule-api/database/migrations/1634413335137_employees.ts
2021-11-15 16:48:20 +01:00

39 lines
1.0 KiB
TypeScript

import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class Employees extends BaseSchema {
protected tableName = 'employees'
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('first_name').notNullable()
table.string('last_name')
table.string('shorthand').unique().notNullable()
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)
.notNullable()
.defaultTo(0)
})
}
public async down () {
this.schema.dropTable(this.tableName)
}
}