Files
dkala-api/database/migrations/Migration20260517132951_AddConfigModule.ts
morteza 2d34fb68e7
deploy to danak / build_and_deploy (push) Has been cancelled
add config module
2026-05-17 17:01:50 +03:30

25 lines
1.4 KiB
TypeScript

import { Migration } from '@mikro-orm/migrations';
export class Migration20260517132951_AddConfigModule extends Migration {
override async up(): Promise<void> {
this.addSql(`create table "configs" ("id" char(26) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "key" varchar(255) not null, "value" varchar(255) not null, "shop_id" char(26) null, constraint "configs_pkey" primary key ("id"));`);
this.addSql(`create index "configs_created_at_index" on "configs" ("created_at");`);
this.addSql(`create index "configs_deleted_at_index" on "configs" ("deleted_at");`);
this.addSql(`alter table "configs" add constraint "configs_shop_id_key_unique" unique ("shop_id", "key");`);
this.addSql(`alter table "configs" add constraint "configs_shop_id_foreign" foreign key ("shop_id") references "shops" ("id") on update cascade on delete set null;`);
this.addSql(`alter table "point_transactions" drop constraint if exists "point_transactions_type_check";`);
this.addSql(`alter table "point_transactions" add constraint "point_transactions_type_check" check("type" in (''));`);
}
override async down(): Promise<void> {
this.addSql(`alter table "point_transactions" drop constraint if exists "point_transactions_type_check";`);
this.addSql(`alter table "point_transactions" add constraint "point_transactions_type_check" check("type" in (''));`);
}
}