import { MigrationInterface, QueryRunner } from "typeorm"

export class AddClientCompanyContactTable1750849349327 implements MigrationInterface {
  name = "AddClientCompanyContactTable1750849349327"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "client_company_contacts" ("id" SERIAL NOT NULL, "client_company_id" integer NOT NULL, "first_name" character varying NOT NULL, "last_name" character varying NOT NULL, "email" character varying NOT NULL, "country_code" character varying NOT NULL, "phone_number" character varying NOT NULL, "position" character varying, "status" character varying NOT NULL DEFAULT 'active', "created_at" TIMESTAMP NOT NULL DEFAULT NOW(), "updated_at" TIMESTAMP NOT NULL DEFAULT NOW(), "deleted_at" TIMESTAMP, CONSTRAINT "PK_f756de404fa12df635b2ec0c0c5" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "client_company_contacts" ADD CONSTRAINT "FK_318c70578835928b816e5ef97cb" FOREIGN KEY ("client_company_id") REFERENCES "clients_companies"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

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