Files
medusa-store/packages/modules/pricing/src/migrations/Migration20241128055359.ts
Harminder Virk 913cf15e2b refactor: migrate pricing entities to DML models (#10335)
Fixes: FRMW-2810

## Breaking changes
There is only one breaking change

- The `min_quantity` and `max_quantity` properties are now consistently typed as numbers. Earlier, it was [typed as numbers](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L68-L69) in some API responses and as [string in others](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L186-L187). I did not go to the bottom of this inconsistency, but the tests reveals them.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-12-02 09:44:41 +00:00

30 lines
1.7 KiB
TypeScript

import { Migration } from '@mikro-orm/migrations';
export class Migration20241128055359 extends Migration {
async up(): Promise<void> {
this.addSql('alter table if exists "price_list" alter column "rules_count" type integer using ("rules_count"::integer);');
this.addSql('alter table if exists "price_list" alter column "rules_count" drop not null;');
this.addSql('alter table if exists "price" alter column "min_quantity" type integer using ("min_quantity"::integer);');
this.addSql('alter table if exists "price" alter column "max_quantity" type integer using ("max_quantity"::integer);');
this.addSql('alter table if exists "price" alter column "rules_count" type integer using ("rules_count"::integer);');
this.addSql('alter table if exists "price" alter column "rules_count" drop not null;');
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_price_rule_price_id" ON "price_rule" (price_id) WHERE deleted_at IS NULL;');
}
async down(): Promise<void> {
this.addSql('alter table if exists "price_list" alter column "rules_count" type integer using ("rules_count"::integer);');
this.addSql('alter table if exists "price_list" alter column "rules_count" set not null;');
this.addSql('alter table if exists "price" alter column "min_quantity" type numeric using ("min_quantity"::numeric);');
this.addSql('alter table if exists "price" alter column "max_quantity" type numeric using ("max_quantity"::numeric);');
this.addSql('alter table if exists "price" alter column "rules_count" type integer using ("rules_count"::integer);');
this.addSql('alter table if exists "price" alter column "rules_count" set not null;');
this.addSql('drop index if exists "IDX_price_rule_price_id";');
}
}