import { MigrationInterface, QueryRunner } from "typeorm"

export class AddTripServicePricingTable1756814464381 implements MigrationInterface {
  name = "AddTripServicePricingTable1756814464381"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "trip_service_pricing" ("id" SERIAL NOT NULL, "trip_id" integer NOT NULL, "charge_type_id" integer, "price" character varying, "quantity" character varying, "total_price" character varying, "created_at" TIMESTAMP NOT NULL DEFAULT NOW(), "updated_at" TIMESTAMP NOT NULL DEFAULT NOW(), "deleted_at" TIMESTAMP, CONSTRAINT "PK_8345df30f95316984723cea80de" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "trip_service_pricing" ADD CONSTRAINT "FK_72a5cf2162d992937c7d662f022" FOREIGN KEY ("trip_id") REFERENCES "trips"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
    await queryRunner.query(
      `ALTER TABLE "trip_service_pricing" ADD CONSTRAINT "FK_5f5c5e0e4f2f5b1823957ece191" FOREIGN KEY ("charge_type_id") REFERENCES "charge_types"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

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