mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
19 lines
557 B
TypeScript
19 lines
557 B
TypeScript
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
|
|
|
|
export default class UsersRoles extends BaseSchema {
|
|
protected tableName = 'users_roles';
|
|
|
|
public async up() {
|
|
this.schema.createTable(this.tableName, table => {
|
|
table.increments('id');
|
|
table.string('user_id', 21).unsigned().references('users.id').onDelete('CASCADE');
|
|
table.integer('role_id').unsigned().references('roles.id').onDelete('CASCADE');
|
|
table.unique(['user_id', 'role_id']);
|
|
});
|
|
}
|
|
|
|
public async down() {
|
|
this.schema.dropTable(this.tableName);
|
|
}
|
|
}
|