|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations"; |
|
2
|
|
|
3
|
export class Migration20241211151053 extends Migration { |
|
4
|
|
|
5
|
async up(): Promise<void> { |
|
6
|
this.addSql('alter table if exists "payment_session" drop constraint if exists "payment_session_payment_collection_id_foreign";'); |
|
7
|
|
|
8
|
this.addSql('alter table if exists "payment" drop constraint if exists "payment_payment_collection_id_foreign";'); |
|
9
|
|
|
10
|
this.addSql('alter table if exists "payment_provider" add column if not exists "created_at" timestamptz not null default now(), add column if not exists "updated_at" timestamptz not null default now(), add column if not exists "deleted_at" timestamptz null;'); |
|
11
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_payment_provider_deleted_at" ON "payment_provider" (deleted_at) WHERE deleted_at IS NULL;'); |
|
12
|
|
|
13
|
this.addSql('alter table if exists "payment_session" alter column "data" type jsonb using ("data"::jsonb);'); |
|
14
|
this.addSql('alter table if exists "payment_session" alter column "data" set default \'{}\';'); |
|
15
|
this.addSql('alter table if exists "payment_session" add constraint "payment_session_payment_collection_id_foreign" foreign key ("payment_collection_id") references "payment_collection" ("id") on update cascade on delete cascade;'); |
|
16
|
|
|
17
|
this.addSql('alter table if exists "payment" add constraint "payment_payment_collection_id_foreign" foreign key ("payment_collection_id") references "payment_collection" ("id") on update cascade on delete cascade;'); |
|
18
|
|
|
19
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_refund_reason_deleted_at" ON "refund_reason" (deleted_at) WHERE deleted_at IS NULL;'); |
|
20
|
|
|
21
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_refund_refund_reason_id" ON "refund" (refund_reason_id) WHERE deleted_at IS NULL;'); |
|
22
|
} |
|
23
|
|
|
24
|
async down(): Promise<void> { |
|
25
|
this.addSql('alter table if exists "payment_session" drop constraint if exists "payment_session_payment_collection_id_foreign";'); |
|
26
|
|
|
27
|
this.addSql('alter table if exists "payment" drop constraint if exists "payment_payment_collection_id_foreign";'); |
|
28
|
|
|
29
|
this.addSql('drop index if exists "IDX_payment_provider_deleted_at";'); |
|
30
|
this.addSql('alter table if exists "payment_provider" drop column if exists "created_at";'); |
|
31
|
this.addSql('alter table if exists "payment_provider" drop column if exists "updated_at";'); |
|
32
|
this.addSql('alter table if exists "payment_provider" drop column if exists "deleted_at";'); |
|
33
|
|
|
34
|
this.addSql('alter table if exists "payment_session" alter column "data" drop default;'); |
|
35
|
this.addSql('alter table if exists "payment_session" alter column "data" type jsonb using ("data"::jsonb);'); |
|
36
|
this.addSql('alter table if exists "payment_session" add constraint "payment_session_payment_collection_id_foreign" foreign key ("payment_collection_id") references "payment_collection" ("id") on update cascade;'); |
|
37
|
|
|
38
|
this.addSql('alter table if exists "payment" add constraint "payment_payment_collection_id_foreign" foreign key ("payment_collection_id") references "payment_collection" ("id") on update cascade;'); |
|
39
|
|
|
40
|
this.addSql('drop index if exists "IDX_refund_reason_deleted_at";'); |
|
41
|
|
|
42
|
this.addSql('drop index if exists "IDX_refund_refund_reason_id";'); |
|
43
|
} |
|
44
|
|
|
45
|
} |