import { MigrationInterface, QueryRunner } from "typeorm"

export class AddTripAddonsPricingTable1756809734668 implements MigrationInterface {
  name = "AddTripAddonsPricingTable1756809734668"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "trip_addons_pricing" ("id" SERIAL NOT NULL, "trip_id" integer NOT NULL, "addons_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_ba293ac9c681532ebf3c7930bfa" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "trip_addons_pricing" ADD CONSTRAINT "FK_efe8bf31352a77d85f3c507e756" FOREIGN KEY ("trip_id") REFERENCES "trips"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
    await queryRunner.query(
      `ALTER TABLE "trip_addons_pricing" ADD CONSTRAINT "FK_62c737eb2444f65b4ae085b31cf" FOREIGN KEY ("addons_id") REFERENCES "add_ons"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

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