1 import { Migration } from "@medusajs/framework/mikro-orm/migrations"
2
3 export class Migration20240821164505 extends Migration {
4 async up(): Promise<void> {
5 this.addSql(
6 'CREATE INDEX IF NOT EXISTS "IDX_order_item_deleted_at" ON "order_item" (deleted_at) WHERE deleted_at IS NOT NULL;'
7 )
8
9 this.addSql(
10 'CREATE INDEX IF NOT EXISTS "IDX_order_summary_deleted_at" ON "order_summary" (deleted_at) WHERE deleted_at IS NOT NULL;'
11 )
12
13 this.addSql(
14 'CREATE INDEX IF NOT EXISTS "IDX_order_claim_item_deleted_at" ON "order_claim_item" (deleted_at) WHERE deleted_at IS NOT NULL;'
15 )
16
17 this.addSql(
18 'CREATE INDEX IF NOT EXISTS "IDX_return_item_deleted_at" ON "return_item" (deleted_at) WHERE deleted_at IS NOT NULL;'
19 )
20
21 this.addSql(
22 'CREATE INDEX IF NOT EXISTS "IDX_order_shipping_deleted_at" ON "order_shipping" (deleted_at) WHERE deleted_at IS NOT NULL;'
23 )
24
25 this.addSql(
26 'CREATE INDEX IF NOT EXISTS "IDX_order_transaction_exchange_id" ON "order_transaction" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL;'
27 )
28
29 this.addSql(
30 'CREATE INDEX IF NOT EXISTS "IDX_order_transaction_claim_id" ON "order_transaction" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL;'
31 )
32 }
33
34 async down(): Promise<void> {
35 this.addSql('drop index if exists "IDX_order_item_deleted_at";')
36 this.addSql('drop index if exists "IDX_order_summary_deleted_at";')
37 this.addSql('drop index if exists "IDX_order_claim_item_deleted_at";')
38 this.addSql('drop index if exists "IDX_return_item_deleted_at";')
39 this.addSql('drop index if exists "IDX_order_shipping_deleted_at";')
40 this.addSql('drop index if exists "IDX_order_transaction_exchange_id";')
41 this.addSql('drop index if exists "IDX_order_transaction_claim_id";')
42 }
43 }