21 lines
622 B
TypeScript
Executable File
21 lines
622 B
TypeScript
Executable File
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
export default class extends BaseSchema {
|
|
protected tableName = 'admin_roles'
|
|
|
|
async up() {
|
|
this.schema.createTable(this.tableName, (table) => {
|
|
table.increments('id')
|
|
table.integer('role_id').unsigned().references('id').inTable('roles').onDelete('CASCADE')
|
|
table.integer('admin_id').unsigned().references('id').inTable('admins').onDelete('CASCADE')
|
|
table.unique(['role_id', 'admin_id'])
|
|
table.timestamp('created_at')
|
|
table.timestamp('updated_at')
|
|
})
|
|
}
|
|
|
|
async down() {
|
|
this.schema.dropTable(this.tableName)
|
|
}
|
|
}
|