import { MigrationInterface, QueryRunner } from "typeorm"

export class InvoiceSettings1759135216609 implements MigrationInterface {
  name = "InvoiceSettings1759135216609"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "invoice_settings" ("id" SERIAL NOT NULL, "notes" character varying, "customer_id" integer, "fields" jsonb, "created_at" TIMESTAMP NOT NULL DEFAULT NOW(), "updated_at" TIMESTAMP NOT NULL DEFAULT NOW(), "deleted_at" TIMESTAMP, CONSTRAINT "REL_c4e71eeef12923463c5810e2a6" UNIQUE ("customer_id"), CONSTRAINT "PK_8145b0482e5c77719fe842c1b05" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "invoice_settings" ADD CONSTRAINT "FK_c4e71eeef12923463c5810e2a6f" FOREIGN KEY ("customer_id") REFERENCES "customers"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

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