import { MigrationInterface, QueryRunner } from "typeorm"

export class AddCarriedForwardDaysToEmployeeLeaveBalances1767010902371 implements MigrationInterface {
  name = "AddCarriedForwardDaysToEmployeeLeaveBalances1767010902371"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "employee_leave_balances" ADD "carried_forward_days" integer NOT NULL DEFAULT 0`,
    )
    await queryRunner.query(
      `ALTER TABLE "employee_salary_history" ADD CONSTRAINT "FK_806928f6221f751561a71abed46" FOREIGN KEY ("updated_by") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "employee_salary_history" DROP CONSTRAINT "FK_806928f6221f751561a71abed46"`,
    )
    await queryRunner.query(
      `ALTER TABLE "employee_leave_balances" DROP COLUMN "carried_forward_days"`,
    )
  }
}
