1 import { Migration } from "@medusajs/framework/mikro-orm/migrations";
2
3 export class Migration20241128055359 extends Migration {
4
5 async up(): Promise<void> {
6 this.addSql('alter table if exists "price_list" alter column "rules_count" type integer using ("rules_count"::integer);');
7 this.addSql('alter table if exists "price_list" alter column "rules_count" drop not null;');
8
9 this.addSql('alter table if exists "price" alter column "min_quantity" type integer using ("min_quantity"::integer);');
10 this.addSql('alter table if exists "price" alter column "max_quantity" type integer using ("max_quantity"::integer);');
11 this.addSql('alter table if exists "price" alter column "rules_count" type integer using ("rules_count"::integer);');
12 this.addSql('alter table if exists "price" alter column "rules_count" drop not null;');
13
14 this.addSql('CREATE INDEX IF NOT EXISTS "IDX_price_rule_price_id" ON "price_rule" (price_id) WHERE deleted_at IS NULL;');
15 }
16
17 async down(): Promise<void> {
18 this.addSql('alter table if exists "price_list" alter column "rules_count" type integer using ("rules_count"::integer);');
19 this.addSql('alter table if exists "price_list" alter column "rules_count" set not null;');
20
21 this.addSql('alter table if exists "price" alter column "min_quantity" type numeric using ("min_quantity"::numeric);');
22 this.addSql('alter table if exists "price" alter column "max_quantity" type numeric using ("max_quantity"::numeric);');
23 this.addSql('alter table if exists "price" alter column "rules_count" type integer using ("rules_count"::integer);');
24 this.addSql('alter table if exists "price" alter column "rules_count" set not null;');
25
26 this.addSql('drop index if exists "IDX_price_rule_price_id";');
27 }
28
29 }