|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20251202184737 extends Migration { |
|
4
|
override async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
`create table if not exists "store_locale" ("id" text not null, "locale_code" text not null, "is_default" boolean not null default false, "store_id" text null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "store_locale_pkey" primary key ("id"));` |
|
7
|
) |
|
8
|
this.addSql( |
|
9
|
`CREATE INDEX IF NOT EXISTS "IDX_store_locale_store_id" ON "store_locale" ("store_id") WHERE deleted_at IS NULL;` |
|
10
|
) |
|
11
|
this.addSql( |
|
12
|
`CREATE INDEX IF NOT EXISTS "IDX_store_locale_deleted_at" ON "store_locale" ("deleted_at") WHERE deleted_at IS NULL;` |
|
13
|
) |
|
14
|
|
|
15
|
this.addSql( |
|
16
|
`alter table if exists "store_locale" add constraint "store_locale_store_id_foreign" foreign key ("store_id") references "store" ("id") on update cascade on delete cascade;` |
|
17
|
) |
|
18
|
} |
|
19
|
|
|
20
|
override async down(): Promise<void> { |
|
21
|
this.addSql(`drop table if exists "store_locale" cascade;`) |
|
22
|
} |
|
23
|
} |