import { MigrationInterface, QueryRunner } from "typeorm"

export class CreateCompanySubscriptionsTable1763545890402 implements MigrationInterface {
  name = "CreateCompanySubscriptionsTable1763545890402"

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
            CREATE TABLE "company_subscriptions" (
                "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,
                "subscription_start_date" date NOT NULL,
                "subscription_end_date" date,
                "duration" integer NOT NULL,
                "duration_type" "public"."company_subscriptions_duration_type_enum" NOT NULL DEFAULT 'Months',
                "subscription_amount" numeric(10,2) NOT NULL,
                "status" "public"."company_subscriptions_status_enum" NOT NULL DEFAULT 'active',
                CONSTRAINT "PK_company_subscriptions_id" PRIMARY KEY ("id")
            )
        `)
  }

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