33 lines
881 B
TypeScript
33 lines
881 B
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.decimal('contract_hours', 2, 2)
|
|
table
|
|
.integer('user_id')
|
|
.unsigned()
|
|
.references('users.id')
|
|
})
|
|
}
|
|
|
|
public async down () {
|
|
this.schema.dropTable(this.tableName)
|
|
}
|
|
}
|