tethys.backend/database/migrations/acl_3_role_has_permissions.ts
Arno Kaimbacher 4714dfdd94 - use latest prettier 3.0 with eslint-plugin-prettier: 5.0.0-alpha.2
- npm normal updates
- add all xslt and style asstes in extra folder public/assets2
- linting corrections
- delete local .env.test from git tracking: git rm --cached .env.test
- add .env.test into .gitignore file
- add edit functionality for editing by submitter
- npm updates
-added xslt3 packeage for builfing sef files
- added Language.ts class vor language table
- added version to datasetxml2oai-pmh.xslt
2023-07-17 19:13:30 +02:00

49 lines
1.9 KiB
TypeScript

import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class RoleHasPermissions extends BaseSchema {
// protected tableName = Config.get('rolePermission.role_permission_table', 'role_permissions')
protected tableName = 'role_has_permissions';
public async up() {
this.schema.createTable(this.tableName, (table) => {
// table.integer('permission_id').notNullable();
// table.integer('role_id').notNullable();
table.integer('permission_id').unsigned().index().notNullable();
table
.foreign('permission_id', 'role_has_permissions_permission_id_foreign')
.references('id')
.inTable('permissions')
.onDelete('CASCADE') // delete this when permission is deleted
.onUpdate('CASCADE');
table.integer('role_id').unsigned().index().notNullable();
table
.foreign('role_id', 'role_has_permissions_role_id_foreign')
.references('id')
.inTable('roles')
.onDelete('CASCADE') // delete this when role is deleted
.onUpdate('CASCADE');
table.primary(['permission_id', 'role_id']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// CREATE TABLE IF NOT EXISTS role_has_permissions
// (
// permission_id integer NOT NULL,
// role_id integer NOT NULL,
// CONSTRAINT role_has_permissions_pkey PRIMARY KEY (permission_id, role_id),
// CONSTRAINT role_has_permissions_permission_id_foreign FOREIGN KEY (permission_id)
// REFERENCES permissions (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT role_has_permissions_role_id_foreign FOREIGN KEY (role_id)
// REFERENCES roles (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE
// )