/* eslint-disable max-len */ // eslint-disable-next-line @typescript-eslint/consistent-type-imports import { MigrationInterface, QueryRunner } from 'typeorm'; export class CreateRainfallVehicle1699360437350 implements MigrationInterface { name = 'CreateRainfallVehicle1699360437350'; public async up(queryRunner: QueryRunner): Promise<void> { await queryRunner.query( `CREATE TYPE "public"."vehicle_records_vehicle_name_enum" AS ENUM('LANDINI', 'YAN MAR', 'KUBOTA')`, ); await queryRunner.query( `CREATE TABLE "vehicle_records" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "date" TIMESTAMP NOT NULL, "vehicle_name" "public"."vehicle_records_vehicle_name_enum" NOT NULL, "hour" numeric(6,2) NOT NULL, "block_id" uuid, CONSTRAINT "PK_f8152a3c5ee74c8eaec30e7149a" PRIMARY KEY ("id"))`, ); await queryRunner.query( `CREATE TABLE "rainfall_records" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "from_time" TIMESTAMP NOT NULL, "to_time" TIMESTAMP NOT NULL, "amount" numeric(20,6) NOT NULL, CONSTRAINT "PK_14bac2b16dc2d6672f32242852e" PRIMARY KEY ("id"))`, ); await queryRunner.query( `ALTER TABLE "ot_settings" ALTER COLUMN "extra_rate_per" SET DEFAULT '1.5'`, ); await queryRunner.query( `ALTER TABLE "vehicle_records" ADD CONSTRAINT "vehicle_record_block" FOREIGN KEY ("block_id") REFERENCES "blocks"("id") ON DELETE NO ACTION ON UPDATE CASCADE`, ); } public async down(queryRunner: QueryRunner): Promise<void> { await queryRunner.query( `ALTER TABLE "vehicle_records" DROP CONSTRAINT "vehicle_record_block"`, ); await queryRunner.query( `ALTER TABLE "ot_settings" ALTER COLUMN "extra_rate_per" SET DEFAULT 1.5`, ); await queryRunner.query(`DROP TABLE "rainfall_records"`); await queryRunner.query(`DROP TABLE "vehicle_records"`); await queryRunner.query( `DROP TYPE "public"."vehicle_records_vehicle_name_enum"`, ); } }