/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-empty-function */
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class UserObjectPermission1671619787598 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
    create table object_permission (
      id integer generated by default as identity,
      account_id integer not null,
      created_at timestamp without time zone not null,
      object_type character varying not null,
      object_id integer,
      create_permission character varying not null,
      view_permission character varying not null,
      edit_permission character varying not null,
      delete_permission character varying not null,
      primary key (id),
      foreign key (account_id) references account(id) on delete cascade
    );
  
    create table user_object_permission (
      user_id integer not null,
      object_permission_id integer not null,
      primary key (user_id, object_permission_id),
      foreign key (user_id) references users(id) on delete cascade,
      foreign key (object_permission_id) references object_permission(id) on delete cascade
    );
    `);
  }

  public async down(_queryRunner: QueryRunner): Promise<void> {}
}
