1 import { Migration } from "@medusajs/framework/mikro-orm/migrations"
2
3 export class Migration20260127081758 extends Migration {
4 override async up(): Promise<void> {
5 this.addSql(
6 `alter table if exists "property_label" drop constraint if exists "property_label_entity_property_unique";`
7 )
8 this.addSql(
9 `create table if not exists "property_label" ("id" text not null, "entity" text not null, "property" text not null, "label" text not null, "description" text null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "property_label_pkey" primary key ("id"));`
10 )
11 this.addSql(
12 `CREATE INDEX IF NOT EXISTS "IDX_property_label_deleted_at" ON "property_label" ("deleted_at") WHERE deleted_at IS NULL;`
13 )
14 this.addSql(
15 `CREATE UNIQUE INDEX IF NOT EXISTS "IDX_property_label_entity_property_unique" ON "property_label" ("entity", "property") WHERE deleted_at IS NULL;`
16 )
17 this.addSql(
18 `CREATE INDEX IF NOT EXISTS "IDX_property_label_entity" ON "property_label" ("entity") WHERE deleted_at IS NULL;`
19 )
20
21 this.addSql(
22 `alter table if exists "view_configuration" alter column "name" type text using ("name"::text);`
23 )
24 this.addSql(
25 `alter table if exists "view_configuration" alter column "name" drop not null;`
26 )
27 }
28
29 override async down(): Promise<void> {
30 this.addSql(`drop table if exists "property_label" cascade;`)
31
32 this.addSql(
33 `alter table if exists "view_configuration" alter column "name" type text using ("name"::text);`
34 )
35 this.addSql(
36 `alter table if exists "view_configuration" alter column "name" set not null;`
37 )
38 }
39 }