Files
admin/backend/database/migrations/1749806811089_create_admins_table.ts
T
2026-06-25 15:53:49 +03:00

30 lines
860 B
TypeScript
Executable File

import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'admins'
async up() {
await this.schema.raw('DROP TYPE IF EXISTS admin_status_enum')
this.schema.createTable(this.tableName, (table) => {
table.increments('id').notNullable()
table.string('email').notNullable().unique()
table.string('password').notNullable()
table.string('first_name').nullable()
table.string('last_name').nullable()
table
.enu('status', ['active', 'inactive'], {
useNative: true,
enumName: 'admin_status_enum',
})
.notNullable()
.defaultTo('active')
table.timestamp('created_at').notNullable()
table.timestamp('updated_at').nullable()
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}