/* eslint-disable canonical/no-unused-exports */ /* eslint-disable max-len */ import { type MigrationInterface, type QueryRunner } from 'typeorm'; export class CreateOtActivityRecord1697818860088 implements MigrationInterface { name = 'CreateOtActivityRecord1697818860088'; public async up(queryRunner: QueryRunner): Promise<void> { await queryRunner.query( `CREATE TABLE "ot_settings" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "normal_rate_per" numeric(20,6) NOT NULL DEFAULT '1', "extra_rate_per" numeric(20,6) NOT NULL DEFAULT '1.5', "meal_allowance_amount" numeric(20,6) NOT NULL DEFAULT '5', "meal_allowance_threshold" numeric(20,6) NOT NULL DEFAULT '3', CONSTRAINT "PK_7cfd77fb9afad985edeb9c5cd9e" PRIMARY KEY ("id"))`, ); await queryRunner.query( `CREATE TYPE "public"."activity_record_settings_incentive_type_enum" AS ENUM('PERCENTAGE', 'FIXED_AMOUNT', 'ON_DECIDE')`, ); await queryRunner.query( `CREATE TABLE "activity_record_settings" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying NOT NULL, "sector" character varying NOT NULL, "rate" numeric(20,6) NOT NULL, "rate_threshold" numeric(20,6) NOT NULL DEFAULT '0', "is_incentive_available" boolean NOT NULL DEFAULT false, "incentive" numeric(20,6) NOT NULL DEFAULT '0', "incentive_threshold" numeric(20,6) NOT NULL DEFAULT '0', "incentive_type" "public"."activity_record_settings_incentive_type_enum" NOT NULL DEFAULT 'FIXED_AMOUNT', CONSTRAINT "UQ_52d4f9f73bf32d4b11433f73e2a" UNIQUE ("name"), CONSTRAINT "PK_7017ce85e7dc4b0a9bb66ff65c1" PRIMARY KEY ("id"))`, ); await queryRunner.query(`ALTER TABLE "employees" DROP COLUMN "daily_rate"`); await queryRunner.query( `ALTER TABLE "employees" DROP COLUMN "monthly_allowance"`, ); await queryRunner.query(`ALTER TABLE "employees" DROP COLUMN "epf_rate"`); await queryRunner.query( `ALTER TABLE "employees" ADD "daily_rate_amount" numeric(20,6) NOT NULL`, ); await queryRunner.query( `ALTER TABLE "employees" ADD "monthly_allowance_amount" numeric(20,6) NOT NULL DEFAULT '0'`, ); await queryRunner.query( `ALTER TABLE "employees" ADD "epf_rate_per" integer NOT NULL DEFAULT '0'`, ); await queryRunner.query( `INSERT INTO "ot_settings" ("id", "normal_rate_per", "extra_rate_per") VALUES ('c8cee0ed-b6e7-4e8a-b53a-e100f065d0ff', DEFAULT, DEFAULT) `, ); } public async down(queryRunner: QueryRunner): Promise<void> { await queryRunner.query( `ALTER TABLE "employees" DROP COLUMN "epf_rate_per"`, ); await queryRunner.query( `ALTER TABLE "employees" DROP COLUMN "monthly_allowance_amount"`, ); await queryRunner.query( `ALTER TABLE "employees" DROP COLUMN "daily_rate_amount"`, ); await queryRunner.query( `ALTER TABLE "employees" ADD "epf_rate" integer NOT NULL DEFAULT '0'`, ); await queryRunner.query( `ALTER TABLE "employees" ADD "monthly_allowance" numeric(20,6) NOT NULL DEFAULT '0'`, ); await queryRunner.query( `ALTER TABLE "employees" ADD "daily_rate" numeric(20,6) NOT NULL`, ); await queryRunner.query(`DROP TABLE "activity_record_settings"`); await queryRunner.query( `DROP TYPE "public"."activity_record_settings_incentive_type_enum"`, ); await queryRunner.query(`DROP TABLE "ot_settings"`); } }