2023-03-17 15:13:37 +00:00
|
|
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
|
|
|
|
import Config from '@ioc:Adonis/Core/Config';
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
export default class Roles extends BaseSchema {
|
2023-03-17 15:13:37 +00:00
|
|
|
protected tableName = Config.get('rolePermission.role_table', 'roles');
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
public async up() {
|
|
|
|
this.schema.createTable(this.tableName, (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
table.string('name', 191).unique();
|
|
|
|
table.string('slug', 191).nullable().unique();
|
|
|
|
table.string('description', 191).nullable();
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
/**
|
|
|
|
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
|
|
|
*/
|
|
|
|
table.timestamp('created_at', { useTz: true }).nullable();
|
|
|
|
table.timestamp('updated_at', { useTz: true }).nullable();
|
|
|
|
});
|
|
|
|
}
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
public async down() {
|
|
|
|
this.schema.dropTable(this.tableName);
|
|
|
|
}
|
2023-03-03 15:54:28 +00:00
|
|
|
}
|