Files
dpage-api/database/migrations/Migration20260521055029.ts
2026-05-21 09:24:03 +03:30

19 lines
1.3 KiB
TypeScript

import { Migration } from '@mikro-orm/migrations';
export class Migration20260521055029 extends Migration {
override async up(): Promise<void> {
this.addSql(`create table "icon_groups" ("id" char(26) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "name" varchar(255) not null, constraint "icon_groups_pkey" primary key ("id"));`);
this.addSql(`create index "icon_groups_created_at_index" on "icon_groups" ("created_at");`);
this.addSql(`create index "icon_groups_deleted_at_index" on "icon_groups" ("deleted_at");`);
this.addSql(`create table "icons" ("id" char(26) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "url" varchar(255) not null, "group_id" char(26) not null, constraint "icons_pkey" primary key ("id"));`);
this.addSql(`create index "icons_created_at_index" on "icons" ("created_at");`);
this.addSql(`create index "icons_deleted_at_index" on "icons" ("deleted_at");`);
this.addSql(`create index "icons_group_id_index" on "icons" ("group_id");`);
this.addSql(`alter table "icons" add constraint "icons_group_id_foreign" foreign key ("group_id") references "icon_groups" ("id") on update cascade;`);
}
}