import { MigrationInterface, QueryRunner } from "typeorm"

export class AddCustomerNumbersEntity1754376407633 implements MigrationInterface {
  name = "AddCustomerNumbersEntity1754376407633"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "customer_phone_numbers" ("id" SERIAL NOT NULL, "customer_id" integer NOT NULL, "country_code" character varying NOT NULL, "phone_number" character varying NOT NULL, "type" character varying, "is_primary" boolean NOT NULL DEFAULT false, CONSTRAINT "PK_dece8a9a58eed91979f97c2459f" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "customer_phone_numbers" ADD CONSTRAINT "FK_946bb91d1f2e8d5acae7010afe1" FOREIGN KEY ("customer_id") REFERENCES "customers"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
    )
  }

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