|
1
|
import { Migration } from '@mikro-orm/migrations'; |
|
2
|
|
|
3
|
export class Migration20251112192723 extends Migration { |
|
4
|
|
|
5
|
override async up(): Promise<void> { |
|
6
|
this.addSql(`drop index if exists "IDX_price_currency_code_price_set_id_min_quantity";`); |
|
7
|
|
|
8
|
this.addSql(`alter table if exists "price" add column if not exists "raw_min_quantity" jsonb null, add column if not exists "raw_max_quantity" jsonb null;`); |
|
9
|
this.addSql(`alter table if exists "price" alter column "min_quantity" type numeric using ("min_quantity"::numeric);`); |
|
10
|
this.addSql(`alter table if exists "price" alter column "max_quantity" type numeric using ("max_quantity"::numeric);`); |
|
11
|
} |
|
12
|
|
|
13
|
override async down(): Promise<void> { |
|
14
|
this.addSql(`alter table if exists "price" drop column if exists "raw_min_quantity", drop column if exists "raw_max_quantity";`); |
|
15
|
|
|
16
|
this.addSql(`alter table if exists "price" alter column "min_quantity" type integer using ("min_quantity"::integer);`); |
|
17
|
this.addSql(`alter table if exists "price" alter column "max_quantity" type integer using ("max_quantity"::integer);`); |
|
18
|
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_price_currency_code_price_set_id_min_quantity" ON "price" (currency_code, price_set_id, min_quantity) WHERE deleted_at IS NULL;`); |
|
19
|
} |
|
20
|
|
|
21
|
} |