|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20240710135844 extends Migration { |
|
4
|
async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
'drop index if exists "IDX_tax_region_unique_country_province";' |
|
7
|
) |
|
8
|
this.addSql( |
|
9
|
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_province" ON "tax_region" (country_code, province_code) WHERE deleted_at IS NULL;' |
|
10
|
) |
|
11
|
this.addSql( |
|
12
|
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_nullable_province" ON "tax_region" (country_code) WHERE province_code IS NULL AND deleted_at IS NULL;' |
|
13
|
) |
|
14
|
} |
|
15
|
|
|
16
|
async down(): Promise<void> { |
|
17
|
this.addSql( |
|
18
|
'drop index if exists "IDX_tax_region_unique_country_province";' |
|
19
|
) |
|
20
|
this.addSql( |
|
21
|
'drop index if exists "IDX_tax_region_unique_country_nullable_province";' |
|
22
|
) |
|
23
|
this.addSql( |
|
24
|
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_province" ON "tax_region" (country_code, province_code);' |
|
25
|
) |
|
26
|
} |
|
27
|
} |