import { MigrationInterface , QueryRunner , Table } from 'typeorm' ; const tableName = 'admin.users_permissions' , usersTableName = 'admin.users' , permissionsTableName = 'admin.permissions' ; /**
 * This table is for the purpose of adding additional permissions to a user
 */ export class createUsersPermissionsTable1610321090667 implements MigrationInterface { public async up ( queryRunner ) { await queryRunner . createTable ( new Table ( { name : tableName , columns : [ { name : 'user_id' , type : 'uuid' , isPrimary : true , isNullable : false , } , { name : 'permission_id' , type : 'integer' , isPrimary : true , isNullable : false , } , ] , foreignKeys : [ { columnNames : [ 'user_id' ] , referencedColumnNames : [ 'id' ] , referencedTableName : usersTableName , onUpdate : 'CASCADE' , } , { columnNames : [ 'permission_id' ] , referencedColumnNames : [ 'id' ] , referencedTableName : permissionsTableName , onUpdate : 'CASCADE' , } , ] , } ) , true ) ; } public async down ( queryRunner ) { await queryRunner . dropTable ( tableName , true , true ) ; } }