import { MigrationInterface, QueryRunner } from "typeorm"

export class AddTripBabySeatsTable1752733761054 implements MigrationInterface {
  name = "AddTripBabySeatsTable1752733761054"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "trip_baby_seats" ("id" SERIAL NOT NULL, "trip_id" integer NOT NULL, "direction" character varying NOT NULL, CONSTRAINT "PK_4c1964b2bd82d020e8d430976bd" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "trip_baby_seats" ADD CONSTRAINT "FK_e16891b7b7b78faefe37ba9107f" FOREIGN KEY ("trip_id") REFERENCES "trips"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
    )
  }

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