import { MigrationInterface, QueryRunner } from "typeorm"

export class CreateCompanyProfilesTable1763545890401 implements MigrationInterface {
  name = "CreateCompanyProfilesTable1763545890401"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
            CREATE TABLE "company_profiles" (
                "created_by" integer,
                "updated_by" integer,
                "deleted_by" integer,
                "created_at" TIMESTAMP NOT NULL DEFAULT NOW(),
                "updated_at" TIMESTAMP NOT NULL DEFAULT NOW(),
                "deleted_at" TIMESTAMP,
                "id" SERIAL NOT NULL,
                "company_id" integer NOT NULL,
                "first_name" character varying(255) NOT NULL,
                "last_name" character varying(255) NOT NULL,
                "email" character varying(255) NOT NULL,
                "phone_number" character varying(20),
                CONSTRAINT "UQ_company_profiles_email" UNIQUE ("email"),
                CONSTRAINT "UQ_company_profiles_company_id" UNIQUE ("company_id"),
                CONSTRAINT "PK_company_profiles_id" PRIMARY KEY ("id")
            )
        `)
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE "company_profiles"`)
  }
}
