import { MigrationInterface, QueryRunner } from "typeorm"

export class AddVehicleModels1747047478234 implements MigrationInterface {
  name = "AddVehicleModels1747047478234"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "vehicle_models" (
        "id" SERIAL NOT NULL,
        "name" character varying NOT NULL,
        "vehicle_manufacture_id" integer NOT NULL,
        "vehicle_type_id" integer NOT NULL,
        "status" smallint NOT NULL DEFAULT '1',
        "created_at" TIMESTAMP DEFAULT NOW(),
        "updated_at" TIMESTAMP DEFAULT NOW(),
        "deleted_at" TIMESTAMP,
        CONSTRAINT "PK_vehicle_models" PRIMARY KEY ("id"),
        CONSTRAINT "FK_vehicle_models_manufacturer" FOREIGN KEY ("vehicle_manufacture_id") REFERENCES "vehicle_manufactures"("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
        CONSTRAINT "FK_vehicle_models_type" FOREIGN KEY ("vehicle_type_id") REFERENCES "vehicle_types"("id") ON DELETE NO ACTION ON UPDATE NO ACTION
      )`,
    )
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE "vehicle_models"`)
  }
}
