Raw
1 import { Migration } from "@medusajs/framework/mikro-orm/migrations"
2
3 export class Migration20241127114534 extends Migration {
4 async up(): Promise<void> {
5 this.addSql(
6 `alter table if exists "price_rule" add column if not exists "operator" text check ("operator" in ('gte', 'lte', 'gt', 'lt', 'eq'));`
7 )
8 this.addSql(
9 `update "price_rule" set "operator" = 'eq' where "operator" is null;`
10 )
11 this.addSql(
12 `alter table "price_rule" alter column "operator" set not null, alter column "operator" set default 'eq';`
13 )
14 this.addSql(
15 'create index if not exists "IDX_price_rule_operator" on "price_rule" ("operator");'
16 )
17 }
18
19 async down(): Promise<void> {
20 this.addSql('drop index if exists "IDX_price_rule_operator";')
21 this.addSql(
22 'alter table if exists "price_rule" drop column if exists "operator";'
23 )
24 }
25 }