import { MigrationInterface, QueryRunner } from "typeorm"

export class CustomerNotificationEntity1760697314448 implements MigrationInterface {
  name = "CustomerNotificationEntity1760697314448"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "customer_notifications" ("id" SERIAL NOT NULL, "customer_id" integer NOT NULL, "title" character varying(255) NOT NULL, "message" text NOT NULL, "data" json, "is_read" boolean NOT NULL DEFAULT false, "created_at" TIMESTAMP DEFAULT NOW(), CONSTRAINT "PK_b6416d72cbf3a2cd898641318c1" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "customer_notifications" ADD CONSTRAINT "FK_f1554a91aa1dae3c4a4159baf23" FOREIGN KEY ("customer_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

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