import { MigrationInterface, QueryRunner } from 'typeorm';

export class SalesPriceFormula1718164344363 implements MigrationInterface {
  name = 'SalesPriceFormula1718164344363';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TYPE "public"."price_formulas_type_enum" AS ENUM('sales price', 'profit share')`,
    );
    await queryRunner.query(
      `CREATE TABLE "price_formulas" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "type" "public"."price_formulas_type_enum" NOT NULL DEFAULT 'sales price', "formula_render" json, "formula_string" character varying, "example_formula" character varying, "example_result" numeric, CONSTRAINT "PK_16b91da2a4659999a3c815e9cf6" PRIMARY KEY ("id"))`,
    );
  }

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