import { MigrationInterface, QueryRunner } from 'typeorm';

export class scopeRights1703192865865 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    queryRunner.query(`
            create table scope_rights
            (
                project_id bigint not null,
                scope_id integer not null,
                user_role_num integer not null,
                rights smallint not null default(0),
                primary key (project_id, scope_id, user_role_num),
                foreign key (scope_id) references scopes(id) ON UPDATE CASCADE ON DELETE CASCADE
            );
        `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    queryRunner.query(`
            drop table scope_rights;
        `);
  }
}
