slider module
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-01 14:11:48 +03:30
parent 18f200df9f
commit e491266ea7
12 changed files with 296 additions and 0 deletions
@@ -0,0 +1,37 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20260701130000_addSlidersTable extends Migration {
override async up(): Promise<void> {
this.addSql(`
create table "sliders" (
"id" char(26) not null,
"created_at" timestamptz not null default now(),
"updated_at" timestamptz not null default now(),
"deleted_at" timestamptz null,
"restaurant_id" char(26) not null,
"image_url" varchar(255) not null,
"title" varchar(255) null,
"link" varchar(255) null,
"order" int not null default 0,
"is_active" boolean not null default true,
constraint "sliders_pkey" primary key ("id")
);
`);
this.addSql(`create index "sliders_created_at_index" on "sliders" ("created_at");`);
this.addSql(`create index "sliders_deleted_at_index" on "sliders" ("deleted_at");`);
this.addSql(`create index "sliders_restaurant_id_index" on "sliders" ("restaurant_id");`);
this.addSql(`create index "sliders_restaurant_id_is_active_index" on "sliders" ("restaurant_id", "is_active");`);
this.addSql(`
alter table "sliders"
add constraint "sliders_restaurant_id_foreign"
foreign key ("restaurant_id") references "restaurants" ("id") on update cascade;
`);
}
override async down(): Promise<void> {
this.addSql(`alter table "sliders" drop constraint if exists "sliders_restaurant_id_foreign";`);
this.addSql(`drop table if exists "sliders" cascade;`);
}
}