Spaces:
Sleeping
Sleeping
import { MigrationInterface, QueryRunner } from "typeorm"; | |
export class RemoveEnums1730549959767 implements MigrationInterface { | |
name = 'RemoveEnums1730549959767' | |
public async up(queryRunner: QueryRunner): Promise<void> { | |
await queryRunner.query(`ALTER TABLE "menu_items" DROP COLUMN "item_type"`); | |
await queryRunner.query(`DROP TYPE "public"."menu_items_item_type_enum"`); | |
await queryRunner.query(`ALTER TABLE "menu_items" ADD "item_type" integer NOT NULL DEFAULT '0'`); | |
await queryRunner.query(`ALTER TABLE "payments" DROP COLUMN "payment_method"`); | |
await queryRunner.query(`DROP TYPE "public"."payments_payment_method_enum"`); | |
await queryRunner.query(`ALTER TABLE "payments" ADD "payment_method" integer NOT NULL DEFAULT '0'`); | |
await queryRunner.query(`ALTER TABLE "orders" DROP COLUMN "order_type"`); | |
await queryRunner.query(`DROP TYPE "public"."orders_order_type_enum"`); | |
await queryRunner.query(`ALTER TABLE "orders" ADD "order_type" integer NOT NULL DEFAULT '0'`); | |
await queryRunner.query(`ALTER TABLE "orders" DROP COLUMN "order_status"`); | |
await queryRunner.query(`DROP TYPE "public"."orders_order_status_enum"`); | |
await queryRunner.query(`ALTER TABLE "orders" ADD "order_status" integer NOT NULL DEFAULT '0'`); | |
} | |
public async down(queryRunner: QueryRunner): Promise<void> { | |
await queryRunner.query(`ALTER TABLE "orders" DROP COLUMN "order_status"`); | |
await queryRunner.query(`CREATE TYPE "public"."orders_order_status_enum" AS ENUM('pending', 'confirmed', 'preparing', 'delivering', 'done')`); | |
await queryRunner.query(`ALTER TABLE "orders" ADD "order_status" "public"."orders_order_status_enum" NOT NULL DEFAULT 'pending'`); | |
await queryRunner.query(`ALTER TABLE "orders" DROP COLUMN "order_type"`); | |
await queryRunner.query(`CREATE TYPE "public"."orders_order_type_enum" AS ENUM('take_away', 'offline', 'online')`); | |
await queryRunner.query(`ALTER TABLE "orders" ADD "order_type" "public"."orders_order_type_enum" NOT NULL DEFAULT 'online'`); | |
await queryRunner.query(`ALTER TABLE "payments" DROP COLUMN "payment_method"`); | |
await queryRunner.query(`CREATE TYPE "public"."payments_payment_method_enum" AS ENUM('cash', 'card', 'online_payment')`); | |
await queryRunner.query(`ALTER TABLE "payments" ADD "payment_method" "public"."payments_payment_method_enum" NOT NULL DEFAULT 'cash'`); | |
await queryRunner.query(`ALTER TABLE "menu_items" DROP COLUMN "item_type"`); | |
await queryRunner.query(`CREATE TYPE "public"."menu_items_item_type_enum" AS ENUM('monchinh', 'trangmieng', 'giaikhat', 'khac')`); | |
await queryRunner.query(`ALTER TABLE "menu_items" ADD "item_type" "public"."menu_items_item_type_enum" NOT NULL DEFAULT 'khac'`); | |
} | |
} | |