import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddTeamPublicAccess1785513600000 implements MigrationInterface {
  name = 'AddTeamPublicAccess1785513600000';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "team" ADD "publicAccessEnabled" boolean NOT NULL DEFAULT false`,
    );
    await queryRunner.query(
      `ALTER TABLE "team" ADD "publicAccessToken" character varying(64)`,
    );
    await queryRunner.query(
      `ALTER TABLE "team" ADD CONSTRAINT "UQ_team_public_access_token" UNIQUE ("publicAccessToken")`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "team" DROP CONSTRAINT "UQ_team_public_access_token"`,
    );
    await queryRunner.query(
      `ALTER TABLE "team" DROP COLUMN "publicAccessToken"`,
    );
    await queryRunner.query(
      `ALTER TABLE "team" DROP COLUMN "publicAccessEnabled"`,
    );
  }
}
