import { MigrationInterface, QueryRunner } from "typeorm"

export class CreateClietnsTable1762408596266 implements MigrationInterface {
  name = "CreateClietnsTable1762408596266"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "clients" ("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, "name" character varying(255) NOT NULL, "phone_number" character varying(255), "email" character varying(255), "status" smallint NOT NULL DEFAULT '1', CONSTRAINT "PK_f1ab7cf3a5714dbc6bb4e1c28a4" PRIMARY KEY ("id"))`,
    )
    await queryRunner.query(
      `ALTER TABLE "clients" ADD CONSTRAINT "FK_fcadfe25d85cf21251273169128" FOREIGN KEY ("company_id") REFERENCES "companies"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    )
  }

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