import { MigrationInterface, QueryRunner } from "typeorm"

export class AddMisReportTable1773126876827 implements MigrationInterface {
  name = "AddMisReportTable1773126876827"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "mis_reports" ("created_by" integer, "updated_by" integer, "deleted_by" integer, "created_at" TIMESTAMP NOT NULL DEFAULT NOW(), "updated_at" TIMESTAMP NOT NULL DEFAULT NOW(), "deleted_at" TIMESTAMP, "id" SERIAL NOT NULL, "company_id" integer NOT NULL, "employee_id" integer NOT NULL, "status" character varying(50) NOT NULL DEFAULT 'pending', "month" smallint NOT NULL, "year" smallint NOT NULL, "business_tasks" text, "technical_tasks" text, "personal_tasks" text, CONSTRAINT "PK_108db5fafd4b4a10b234bac5d41" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "mis_reports" ADD CONSTRAINT "FK_efded81f170ad6e47d2003cedd2" FOREIGN KEY ("company_id") REFERENCES "companies"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
    await queryRunner.query(
      `ALTER TABLE "mis_reports" ADD CONSTRAINT "FK_e3556d65a5b8314c69e7bc46993" FOREIGN KEY ("employee_id") REFERENCES "employees"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "mis_reports" DROP CONSTRAINT "FK_e3556d65a5b8314c69e7bc46993"`,
    )
    await queryRunner.query(
      `ALTER TABLE "mis_reports" DROP CONSTRAINT "FK_efded81f170ad6e47d2003cedd2"`,
    )
    await queryRunner.query(`DROP TABLE "mis_reports"`)
  }
}
