Files
dmenu-api/database/migrations/Migration20260607131845.ts
T
morteza 89fa1d637e
deploy to danak / build_and_deploy (push) Has been cancelled
add credit card payment method
2026-06-07 16:56:55 +03:30

32 lines
1.7 KiB
TypeScript

import { Migration } from '@mikro-orm/migrations';
export class Migration20260607131845 extends Migration {
override async up(): Promise<void> {
this.addSql(`update "payment_methods" set "method" = 'CreditCard' where "method" = 'Cart';`);
this.addSql(`update "payments" set "method" = 'CreditCard' where "method" = 'Cart';`);
this.addSql(`alter table "payment_methods" drop constraint if exists "payment_methods_method_check";`);
this.addSql(`alter table "payments" drop constraint if exists "payments_method_check";`);
this.addSql(`alter table "payments" add column if not exists "attachments" jsonb null;`);
this.addSql(`alter table "payment_methods" add constraint "payment_methods_method_check" check("method" in ('Online', 'Cash', 'Wallet', 'CreditCard'));`);
this.addSql(`alter table "payments" add constraint "payments_method_check" check("method" in ('Online', 'Cash', 'Wallet', 'CreditCard'));`);
}
override async down(): Promise<void> {
this.addSql(`alter table "payment_methods" drop constraint if exists "payment_methods_method_check";`);
this.addSql(`alter table "payments" drop constraint if exists "payments_method_check";`);
this.addSql(`update "payment_methods" set "method" = 'Cart' where "method" = 'CreditCard';`);
this.addSql(`update "payments" set "method" = 'Cart' where "method" = 'CreditCard';`);
this.addSql(`alter table "payments" drop column if exists "attachments";`);
this.addSql(`alter table "payment_methods" add constraint "payment_methods_method_check" check("method" in ('Online', 'Cash', 'Wallet', 'Cart'));`);
this.addSql(`alter table "payments" add constraint "payments_method_check" check("method" in ('Online', 'Cash', 'Wallet', 'Cart'));`);
}
}