created User-Model and Employee-Model
This commit is contained in:
1
database/factories/index.ts
Normal file
1
database/factories/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
// import Factory from '@ioc:Adonis/Lucid/Factory'
|
||||
32
database/migrations/1634413335137_employees.ts
Normal file
32
database/migrations/1634413335137_employees.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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 ')
|
||||
table.string('last_name')
|
||||
table.string('shorthand').unique()
|
||||
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)
|
||||
}
|
||||
}
|
||||
25
database/migrations/1634414150546_users.ts
Normal file
25
database/migrations/1634414150546_users.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user