1 import { Migration } from "@medusajs/framework/mikro-orm/migrations"
2
3 export class Migration20240821170957 extends Migration {
4 async up(): Promise<void> {
5 this.addSql(
6 'alter table if exists "shipping_option" drop constraint if exists "shipping_option_price_type_check";'
7 )
8
9 this.addSql(
10 'alter table if exists "shipping_option" drop constraint if exists "shipping_option_fulfillment_provider_id_foreign";'
11 )
12
13 this.addSql(
14 'alter table if exists "shipping_option" alter column "price_type" type text using ("price_type"::text);'
15 )
16 this.addSql(
17 'alter table if exists "shipping_option" add constraint "shipping_option_price_type_check" check ("price_type" in (\'calculated\', \'flat\'));'
18 )
19 this.addSql(
20 'alter table if exists "shipping_option" alter column "price_type" set default \'flat\';'
21 )
22 this.addSql(
23 'alter table if exists "fulfillment" add column if not exists "marked_shipped_by" text null, add column if not exists "created_by" text null;'
24 )
25 }
26
27 async down(): Promise<void> {
28 this.addSql(
29 'alter table if exists "shipping_option" drop constraint if exists "shipping_option_price_type_check";'
30 )
31 this.addSql(
32 'alter table if exists "shipping_option" alter column "price_type" type text using ("price_type"::text);'
33 )
34 this.addSql(
35 'alter table if exists "shipping_option" add constraint "shipping_option_price_type_check" check ("price_type" in (\'calculated\', \'flat\'));'
36 )
37 this.addSql(
38 'alter table if exists "shipping_option" alter column "price_type" set default \'calculated\';'
39 )
40 this.addSql(
41 'alter table if exists "fulfillment" drop column if exists "marked_shipped_by";'
42 )
43 this.addSql(
44 'alter table if exists "fulfillment" drop column if exists "created_by";'
45 )
46 }
47 }