|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations"; |
|
2
|
|
|
3
|
export class Migration20260615151246 extends Migration { |
|
4
|
|
|
5
|
override async up(): Promise<void> { |
|
6
|
this.addSql(`alter table if exists "layout_configuration" drop constraint if exists "layout_configuration_zone_unique";`); |
|
7
|
this.addSql(`alter table if exists "layout_configuration" drop constraint if exists "layout_configuration_zone_user_id_unique";`); |
|
8
|
this.addSql(`create table if not exists "layout_configuration" ("id" text not null, "zone" text not null, "user_id" text null, "is_system_default" boolean not null default false, "configuration" jsonb not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "layout_configuration_pkey" primary key ("id"));`); |
|
9
|
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_layout_configuration_deleted_at" ON "layout_configuration" ("deleted_at") WHERE deleted_at IS NULL;`); |
|
10
|
this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_layout_configuration_zone_user_id_unique" ON "layout_configuration" ("zone", "user_id") WHERE deleted_at IS NULL;`); |
|
11
|
this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_layout_configuration_zone_unique" ON "layout_configuration" ("zone") WHERE is_system_default = true AND deleted_at IS NULL;`); |
|
12
|
} |
|
13
|
|
|
14
|
override async down(): Promise<void> { |
|
15
|
this.addSql(`drop table if exists "layout_configuration" cascade;`); |
|
16
|
} |
|
17
|
|
|
18
|
} |