update customers

This commit is contained in:
2026-06-18 20:15:05 +03:30
parent e1823d2722
commit 136b067d37
8 changed files with 285 additions and 18 deletions
+177
View File
@@ -1113,6 +1113,16 @@
"length": 255,
"mappedType": "string"
},
"card_owner": {
"name": "card_owner",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 255,
"mappedType": "string"
},
"enabled": {
"name": "enabled",
"type": "boolean",
@@ -5428,6 +5438,173 @@
},
"nativeEnums": {}
},
{
"columns": {
"id": {
"name": "id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"created_at": {
"name": "created_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"updated_at": {
"name": "updated_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"default": "now()",
"mappedType": "datetime"
},
"deleted_at": {
"name": "deleted_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 6,
"mappedType": "datetime"
},
"user_id": {
"name": "user_id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"restaurant_id": {
"name": "restaurant_id",
"type": "char(26)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 26,
"mappedType": "character"
},
"order_count": {
"name": "order_count",
"type": "int",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"mappedType": "integer"
},
"total_order_amount": {
"name": "total_order_amount",
"type": "int",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"mappedType": "integer"
}
},
"name": "user_restuarant",
"schema": "public",
"indexes": [
{
"keyName": "user_restuarant_created_at_index",
"columnNames": [
"created_at"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "user_restuarant_deleted_at_index",
"columnNames": [
"deleted_at"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "user_restuarant_restaurant_id_index",
"columnNames": [
"restaurant_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "user_restuarant_user_id_restaurant_id_unique",
"columnNames": [
"user_id",
"restaurant_id"
],
"composite": true,
"constraint": true,
"primary": false,
"unique": true
},
{
"keyName": "user_restuarant_pkey",
"columnNames": [
"id"
],
"composite": false,
"constraint": true,
"primary": true,
"unique": true
}
],
"checks": [],
"foreignKeys": {
"user_restuarant_user_id_foreign": {
"constraintName": "user_restuarant_user_id_foreign",
"columnNames": [
"user_id"
],
"localTableName": "public.user_restuarant",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.users",
"updateRule": "cascade"
},
"user_restuarant_restaurant_id_foreign": {
"constraintName": "user_restuarant_restaurant_id_foreign",
"columnNames": [
"restaurant_id"
],
"localTableName": "public.user_restuarant",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.restaurants",
"updateRule": "cascade"
}
},
"nativeEnums": {}
},
{
"columns": {
"id": {
@@ -0,0 +1,20 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20260618162454_add_user_restuarant_table extends Migration {
override async up(): Promise<void> {
this.addSql(`create table "user_restuarant" ("id" char(26) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "user_id" char(26) not null, "restaurant_id" char(26) not null, "order_count" int not null, "total_order_amount" int not null, constraint "user_restuarant_pkey" primary key ("id"));`);
this.addSql(`create index "user_restuarant_created_at_index" on "user_restuarant" ("created_at");`);
this.addSql(`create index "user_restuarant_deleted_at_index" on "user_restuarant" ("deleted_at");`);
this.addSql(`create index "user_restuarant_restaurant_id_index" on "user_restuarant" ("restaurant_id");`);
this.addSql(`alter table "user_restuarant" add constraint "user_restuarant_user_id_restaurant_id_unique" unique ("user_id", "restaurant_id");`);
this.addSql(`alter table "user_restuarant" add constraint "user_restuarant_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade;`);
this.addSql(`alter table "user_restuarant" add constraint "user_restuarant_restaurant_id_foreign" foreign key ("restaurant_id") references "restaurants" ("id") on update cascade;`);
}
override async down(): Promise<void> {
this.addSql(`drop table if exists "user_restuarant";`);
}
}