From a1ca2a62c852758626e49d2245b63dabbbde1cb9 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 10 Jan 2026 11:14:27 +0330 Subject: [PATCH] production --- database/migrations/.snapshot-postgres.json | 5653 ----------------- .../migrations/Migration20260105085439.ts | 27 - .../migrations/Migration20260106054151.ts | 23 - .../migrations/Migration20260106192946.ts | 14 - src/common/entities/base.entity.ts | 18 +- .../controllers/category.controller.ts | 89 - src/modules/product/crone/product.crone.ts | 45 - .../entities/attribute-value.entity.ts | 22 + .../product/entities/attribute.entity.ts | 19 + .../product/entities/category.entity.ts | 27 - .../product/entities/favorite.entity.ts | 14 - src/modules/product/entities/food.entity.ts | 23 - .../product/entities/product.entity.ts | 9 +- .../product/interface/product.interface.ts | 13 +- src/modules/product/product.module.ts | 15 +- .../product/providers/category.service.ts | 111 - .../product/providers/product.service.ts | 12 +- .../repositories/category.repository.ts | 10 - src/seeders/data/categories.data.ts | 1 + 19 files changed, 64 insertions(+), 6081 deletions(-) delete mode 100644 database/migrations/.snapshot-postgres.json delete mode 100644 database/migrations/Migration20260105085439.ts delete mode 100644 database/migrations/Migration20260106054151.ts delete mode 100644 database/migrations/Migration20260106192946.ts delete mode 100644 src/modules/product/controllers/category.controller.ts delete mode 100644 src/modules/product/crone/product.crone.ts create mode 100644 src/modules/product/entities/attribute-value.entity.ts create mode 100644 src/modules/product/entities/attribute.entity.ts delete mode 100644 src/modules/product/entities/category.entity.ts delete mode 100644 src/modules/product/entities/favorite.entity.ts delete mode 100644 src/modules/product/entities/food.entity.ts delete mode 100644 src/modules/product/providers/category.service.ts delete mode 100644 src/modules/product/repositories/category.repository.ts diff --git a/database/migrations/.snapshot-postgres.json b/database/migrations/.snapshot-postgres.json deleted file mode 100644 index 613ad2f..0000000 --- a/database/migrations/.snapshot-postgres.json +++ /dev/null @@ -1,5653 +0,0 @@ -{ - "namespaces": [ - "public" - ], - "name": "public", - "tables": [ - { - "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" - }, - "first_name": { - "name": "first_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "last_name": { - "name": "last_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - } - }, - "name": "admins", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "phone" - ], - "composite": false, - "keyName": "admins_phone_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "admins_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "admins_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "admins_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "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" - }, - "name": { - "name": "name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - } - }, - "name": "icon_groups", - "schema": "public", - "indexes": [ - { - "keyName": "icon_groups_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "icon_groups_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "icon_groups_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "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" - }, - "url": { - "name": "url", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "group_id": { - "name": "group_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - } - }, - "name": "icons", - "schema": "public", - "indexes": [ - { - "keyName": "icons_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "icons_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "icons_group_id_index", - "columnNames": [ - "group_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "icons_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "icons_group_id_foreign": { - "constraintName": "icons_group_id_foreign", - "columnNames": [ - "group_id" - ], - "localTableName": "public.icons", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.icon_groups", - "updateRule": "cascade" - } - }, - "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" - }, - "name": { - "name": "name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - } - }, - "name": "permissions", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "name" - ], - "composite": false, - "keyName": "permissions_name_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "permissions_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "permissions_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "permissions_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "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" - }, - "hashed_token": { - "name": "hashed_token", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "owner_id": { - "name": "owner_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "rest_id": { - "name": "rest_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "user", - "admin" - ], - "mappedType": "enum" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "refreshtokens", - "schema": "public", - "indexes": [ - { - "keyName": "refreshtokens_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "refreshtokens_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "refreshtokens_expires_at_index", - "columnNames": [ - "expires_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "refreshtokens_hashed_token_index", - "columnNames": [ - "hashed_token" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "refreshtokens_owner_id_rest_id_type_index", - "columnNames": [ - "owner_id", - "rest_id", - "type" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "refreshtokens_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "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" - }, - "name": { - "name": "name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "logo": { - "name": "logo", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "address": { - "name": "address", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "menu_color": { - "name": "menu_color", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "latitude": { - "name": "latitude", - "type": "numeric(10,7)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 7, - "mappedType": "decimal" - }, - "longitude": { - "name": "longitude", - "type": "numeric(10,7)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 7, - "mappedType": "decimal" - }, - "service_area": { - "name": "service_area", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "established_year": { - "name": "established_year", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "instagram": { - "name": "instagram", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "telegram": { - "name": "telegram", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "whatsapp": { - "name": "whatsapp", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "description": { - "name": "description", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "seo_title": { - "name": "seo_title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "seo_description": { - "name": "seo_description", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "tag_names": { - "name": "tag_names", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "images": { - "name": "images", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "vat": { - "name": "vat", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "domain": { - "name": "domain", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "score": { - "name": "score", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "plan": { - "name": "plan", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'base'", - "enumItems": [ - "base", - "premium" - ], - "mappedType": "enum" - }, - "subscription_id": { - "name": "subscription_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "subscription_end_date": { - "name": "subscription_end_date", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "subscription_start_date": { - "name": "subscription_start_date", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "restaurants", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "slug" - ], - "composite": false, - "keyName": "restaurants_slug_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "columnNames": [ - "subscription_id" - ], - "composite": false, - "keyName": "restaurants_subscription_id_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "restaurants_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "restaurants_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "restaurants_slug_is_active_index", - "columnNames": [ - "slug", - "is_active" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "restaurants_is_active_index", - "columnNames": [ - "is_active" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "restaurants_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "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" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "method": { - "name": "method", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "Online", - "Cash", - "Wallet" - ], - "mappedType": "enum" - }, - "gateway": { - "name": "gateway", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "enumItems": [ - "zarinpal" - ], - "mappedType": "enum" - }, - "description": { - "name": "description", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "enabled": { - "name": "enabled", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - }, - "merchant_id": { - "name": "merchant_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - } - }, - "name": "payment_methods", - "schema": "public", - "indexes": [ - { - "keyName": "payment_methods_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "payment_methods_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "payment_methods_restaurant_id_enabled_index", - "columnNames": [ - "restaurant_id", - "enabled" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "payment_methods_restaurant_id_method_unique", - "columnNames": [ - "restaurant_id", - "method" - ], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "payment_methods_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "payment_methods_restaurant_id_foreign": { - "constraintName": "payment_methods_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.payment_methods", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - } - }, - "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" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "channels": { - "name": "channels", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - } - }, - "name": "notification_preferences", - "schema": "public", - "indexes": [ - { - "keyName": "notification_preferences_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "notification_preferences_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "notification_preferences_restaurant_id_title_unique", - "columnNames": [ - "restaurant_id", - "title" - ], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "notification_preferences_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "notification_preferences_restaurant_id_foreign": { - "constraintName": "notification_preferences_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.notification_preferences", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - } - }, - "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" - }, - "method": { - "name": "method", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "dineIn", - "customerPickup", - "deliveryCar", - "deliveryCourier" - ], - "mappedType": "enum" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "delivery_fee": { - "name": "delivery_fee", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "delivery_fee_type": { - "name": "delivery_fee_type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'fixed'", - "enumItems": [ - "fixed", - "distanceBased" - ], - "mappedType": "enum" - }, - "per_kilometer_fee": { - "name": "per_kilometer_fee", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "distance_based_min_cost": { - "name": "distance_based_min_cost", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "min_order_price": { - "name": "min_order_price", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "description": { - "name": "description", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "enabled": { - "name": "enabled", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - } - }, - "name": "deliveries", - "schema": "public", - "indexes": [ - { - "keyName": "deliveries_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "deliveries_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "deliveries_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "deliveries_restaurant_id_foreign": { - "constraintName": "deliveries_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.deliveries", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - } - }, - "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" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "code": { - "name": "code", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "description": { - "name": "description", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "PERCENTAGE", - "FIXED" - ], - "mappedType": "enum" - }, - "value": { - "name": "value", - "type": "numeric(10,2)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 2, - "mappedType": "decimal" - }, - "max_discount": { - "name": "max_discount", - "type": "numeric(10,2)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 2, - "mappedType": "decimal" - }, - "min_order_amount": { - "name": "min_order_amount", - "type": "numeric(10,2)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 2, - "mappedType": "decimal" - }, - "max_uses": { - "name": "max_uses", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "used_count": { - "name": "used_count", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - }, - "max_uses_per_user": { - "name": "max_uses_per_user", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "start_date": { - "name": "start_date", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "end_date": { - "name": "end_date", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "product_categories": { - "name": "product_categories", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "products": { - "name": "products", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "user_phone": { - "name": "user_phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - } - }, - "name": "coupons", - "schema": "public", - "indexes": [ - { - "keyName": "coupons_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "coupons_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "coupons_code_index", - "columnNames": [ - "code" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "coupons_restaurant_id_is_active_index", - "columnNames": [ - "restaurant_id", - "is_active" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "coupons_restaurant_id_code_is_active_index", - "columnNames": [ - "restaurant_id", - "code", - "is_active" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "coupons_code_restaurant_id_unique", - "columnNames": [ - "code", - "restaurant_id" - ], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "coupons_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "coupons_restaurant_id_foreign": { - "constraintName": "coupons_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.coupons", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - } - }, - "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" - }, - "subject": { - "name": "subject", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "content": { - "name": "content", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "scope": { - "name": "scope", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "application", - "restaurant" - ], - "mappedType": "enum" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "status": { - "name": "status", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "default": "'new'", - "mappedType": "string" - } - }, - "name": "contacts", - "schema": "public", - "indexes": [ - { - "keyName": "contacts_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "contacts_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "contacts_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "contacts_restaurant_id_foreign": { - "constraintName": "contacts_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.contacts", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "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" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "avatar_url": { - "name": "avatar_url", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - } - }, - "name": "categories", - "schema": "public", - "indexes": [ - { - "keyName": "categories_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "categories_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "categories_is_active_index", - "columnNames": [ - "is_active" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "categories_restaurant_id_is_active_index", - "columnNames": [ - "restaurant_id", - "is_active" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "categories_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "categories_restaurant_id_foreign": { - "constraintName": "categories_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.categories", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - } - }, - "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" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "category_id": { - "name": "category_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "desc": { - "name": "desc", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "content": { - "name": "content", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "price": { - "name": "price", - "type": "numeric(10,2)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 2, - "mappedType": "decimal" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "prepare_time": { - "name": "prepare_time", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "week_days": { - "name": "week_days", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'[]'", - "mappedType": "json" - }, - "meal_types": { - "name": "meal_types", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'[]'", - "mappedType": "json" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "images": { - "name": "images", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "in_place_serve": { - "name": "in_place_serve", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - }, - "pickup_serve": { - "name": "pickup_serve", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - }, - "score": { - "name": "score", - "type": "real", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "default": "null", - "mappedType": "float" - }, - "discount": { - "name": "discount", - "type": "real", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "float" - }, - "is_special_offer": { - "name": "is_special_offer", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - } - }, - "name": "products", - "schema": "public", - "indexes": [ - { - "keyName": "products_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "products_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "products_is_active_index", - "columnNames": [ - "is_active" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "products_category_id_is_active_index", - "columnNames": [ - "category_id", - "is_active" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "products_restaurant_id_is_active_index", - "columnNames": [ - "restaurant_id", - "is_active" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "products_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "products_restaurant_id_foreign": { - "constraintName": "products_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.products", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - }, - "products_category_id_foreign": { - "constraintName": "products_category_id_foreign", - "columnNames": [ - "category_id" - ], - "localTableName": "public.products", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.categories", - "updateRule": "cascade" - } - }, - "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" - }, - "product_id": { - "name": "product_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "total_stock": { - "name": "total_stock", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "available_stock": { - "name": "available_stock", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - } - }, - "name": "inventory", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "product_id" - ], - "composite": false, - "keyName": "inventory_product_id_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "inventory_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "inventory_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "inventory_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "inventory_product_id_foreign": { - "constraintName": "inventory_product_id_foreign", - "columnNames": [ - "product_id" - ], - "localTableName": "public.inventory", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.products", - "deleteRule": "cascade", - "updateRule": "cascade" - } - }, - "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" - }, - "name": { - "name": "name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - } - }, - "name": "roles", - "schema": "public", - "indexes": [ - { - "keyName": "roles_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "roles_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "roles_restaurant_id_index", - "columnNames": [ - "restaurant_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "roles_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "roles_restaurant_id_foreign": { - "constraintName": "roles_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.roles", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "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" - }, - "admin_id": { - "name": "admin_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "role_id": { - "name": "role_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": true, - "length": 26, - "mappedType": "character" - } - }, - "name": "admin_roles", - "schema": "public", - "indexes": [ - { - "keyName": "admin_roles_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "admin_roles_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "admin_roles_restaurant_id_index", - "columnNames": [ - "restaurant_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "admin_roles_admin_id_index", - "columnNames": [ - "admin_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "admin_roles_admin_id_restaurant_id_index", - "columnNames": [ - "admin_id", - "restaurant_id" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "admin_roles_admin_id_restaurant_id_unique", - "columnNames": [ - "admin_id", - "restaurant_id" - ], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "admin_roles_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "admin_roles_admin_id_foreign": { - "constraintName": "admin_roles_admin_id_foreign", - "columnNames": [ - "admin_id" - ], - "localTableName": "public.admin_roles", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "updateRule": "cascade" - }, - "admin_roles_role_id_foreign": { - "constraintName": "admin_roles_role_id_foreign", - "columnNames": [ - "role_id" - ], - "localTableName": "public.admin_roles", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.roles", - "updateRule": "cascade" - }, - "admin_roles_restaurant_id_foreign": { - "constraintName": "admin_roles_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.admin_roles", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "role_id": { - "name": "role_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "permission_id": { - "name": "permission_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - } - }, - "name": "role_permissions", - "schema": "public", - "indexes": [ - { - "keyName": "role_permissions_pkey", - "columnNames": [ - "role_id", - "permission_id" - ], - "composite": true, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "role_permissions_role_id_foreign": { - "constraintName": "role_permissions_role_id_foreign", - "columnNames": [ - "role_id" - ], - "localTableName": "public.role_permissions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.roles", - "updateRule": "cascade" - }, - "role_permissions_permission_id_foreign": { - "constraintName": "role_permissions_permission_id_foreign", - "columnNames": [ - "permission_id" - ], - "localTableName": "public.role_permissions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.permissions", - "updateRule": "cascade" - } - }, - "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" - }, - "week_day": { - "name": "week_day", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "open_time": { - "name": "open_time", - "type": "time(0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 0, - "mappedType": "time" - }, - "close_time": { - "name": "close_time", - "type": "time(0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 0, - "mappedType": "time" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "rest_id": { - "name": "rest_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - } - }, - "name": "schedules", - "schema": "public", - "indexes": [ - { - "keyName": "schedules_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "schedules_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "schedules_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "serial", - "unsigned": false, - "autoincrement": true, - "primary": true, - "nullable": false, - "mappedType": "integer" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "sms_logs", - "schema": "public", - "indexes": [ - { - "keyName": "sms_logs_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "sms_logs_restaurant_id_foreign": { - "constraintName": "sms_logs_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.sms_logs", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - } - }, - "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" - }, - "first_name": { - "name": "first_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "last_name": { - "name": "last_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "birth_date": { - "name": "birth_date", - "type": "date", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 0, - "default": "null", - "mappedType": "date" - }, - "marriage_date": { - "name": "marriage_date", - "type": "date", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 0, - "default": "null", - "mappedType": "date" - }, - "referrer": { - "name": "referrer", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "gender": { - "name": "gender", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "default": "true", - "mappedType": "boolean" - }, - "avatar_url": { - "name": "avatar_url", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - } - }, - "name": "users", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "phone" - ], - "composite": false, - "keyName": "users_phone_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "users_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "users_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "users_is_active_index", - "columnNames": [ - "is_active" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "users_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "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" - }, - "amount": { - "name": "amount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "balance": { - "name": "balance", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [], - "mappedType": "enum" - }, - "reason": { - "name": "reason", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "order_completed_deposit", - "convert_score_to_point" - ], - "mappedType": "enum" - } - }, - "name": "point_transactions", - "schema": "public", - "indexes": [ - { - "keyName": "point_transactions_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "point_transactions_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "point_transactions_restaurant_id_index", - "columnNames": [ - "restaurant_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "point_transactions_user_id_index", - "columnNames": [ - "user_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "point_transactions_user_id_restaurant_id_index", - "columnNames": [ - "user_id", - "restaurant_id" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "point_transactions_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "point_transactions_user_id_foreign": { - "constraintName": "point_transactions_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.point_transactions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - }, - "point_transactions_restaurant_id_foreign": { - "constraintName": "point_transactions_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.point_transactions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - } - }, - "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" - }, - "cookie_id": { - "name": "cookie_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "table_number": { - "name": "table_number", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "user_id": { - "name": "user_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "staff_id": { - "name": "staff_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "message": { - "name": "message", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'pending'", - "enumItems": [ - "pending", - "acknowledged", - "rejected", - "completed" - ], - "mappedType": "enum" - } - }, - "name": "pagers", - "schema": "public", - "indexes": [ - { - "keyName": "pagers_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "pagers_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "pagers_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "pagers_restaurant_id_foreign": { - "constraintName": "pagers_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.pagers", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - }, - "pagers_user_id_foreign": { - "constraintName": "pagers_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.pagers", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "pagers_staff_id_foreign": { - "constraintName": "pagers_staff_id_foreign", - "columnNames": [ - "staff_id" - ], - "localTableName": "public.pagers", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "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" - }, - "delivery_method_id": { - "name": "delivery_method_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "user_address": { - "name": "user_address", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "car_address": { - "name": "car_address", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "order_number": { - "name": "order_number", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "coupon_discount": { - "name": "coupon_discount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "coupon_detail": { - "name": "coupon_detail", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "items_discount": { - "name": "items_discount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "total_discount": { - "name": "total_discount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "sub_total": { - "name": "sub_total", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "tax": { - "name": "tax", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "delivery_fee": { - "name": "delivery_fee", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "total": { - "name": "total", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "total_items": { - "name": "total_items", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - }, - "description": { - "name": "description", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "table_number": { - "name": "table_number", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "pendingPayment", - "paid", - "preparing", - "deliveredToWaiter", - "deliveredToReceptionist", - "shipped", - "completed", - "canceled" - ], - "mappedType": "enum" - }, - "history": { - "name": "history", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - } - }, - "name": "orders", - "schema": "public", - "indexes": [ - { - "keyName": "orders_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "orders_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "orders_status_index", - "columnNames": [ - "status" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "orders_restaurant_id_order_number_index", - "columnNames": [ - "restaurant_id", - "order_number" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "orders_user_id_status_index", - "columnNames": [ - "user_id", - "status" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "orders_restaurant_id_status_index", - "columnNames": [ - "restaurant_id", - "status" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "orders_restaurant_id_order_number_unique", - "columnNames": [ - "restaurant_id", - "order_number" - ], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "orders_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "orders_user_id_foreign": { - "constraintName": "orders_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.orders", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - }, - "orders_restaurant_id_foreign": { - "constraintName": "orders_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.orders", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - }, - "orders_delivery_method_id_foreign": { - "constraintName": "orders_delivery_method_id_foreign", - "columnNames": [ - "delivery_method_id" - ], - "localTableName": "public.orders", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.deliveries", - "updateRule": "cascade" - }, - "orders_payment_method_id_foreign": { - "constraintName": "orders_payment_method_id_foreign", - "columnNames": [ - "payment_method_id" - ], - "localTableName": "public.orders", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment_methods", - "updateRule": "cascade" - } - }, - "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" - }, - "order_id": { - "name": "order_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "product_id": { - "name": "product_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "user_id": { - "name": "user_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "comment": { - "name": "comment", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "rating": { - "name": "rating", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - }, - "positive_points": { - "name": "positive_points", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "negative_points": { - "name": "negative_points", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'pending'", - "enumItems": [ - "pending", - "rejected", - "approved" - ], - "mappedType": "enum" - } - }, - "name": "reviews", - "schema": "public", - "indexes": [ - { - "keyName": "reviews_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "reviews_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "reviews_order_id_index", - "columnNames": [ - "order_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "reviews_user_id_index", - "columnNames": [ - "user_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "reviews_product_id_status_index", - "columnNames": [ - "product_id", - "status" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "reviews_order_id_product_id_user_id_unique", - "columnNames": [ - "order_id", - "product_id", - "user_id" - ], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "reviews_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "reviews_order_id_foreign": { - "constraintName": "reviews_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.reviews", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.orders", - "updateRule": "cascade" - }, - "reviews_product_id_foreign": { - "constraintName": "reviews_product_id_foreign", - "columnNames": [ - "product_id" - ], - "localTableName": "public.reviews", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.products", - "updateRule": "cascade" - }, - "reviews_user_id_foreign": { - "constraintName": "reviews_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.reviews", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - } - }, - "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" - }, - "order_id": { - "name": "order_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "amount": { - "name": "amount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "reference_id": { - "name": "reference_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "method": { - "name": "method", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "Online", - "Cash", - "Wallet" - ], - "mappedType": "enum" - }, - "gateway": { - "name": "gateway", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "enumItems": [ - "zarinpal" - ], - "mappedType": "enum" - }, - "transaction_id": { - "name": "transaction_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "pending", - "paid", - "failed", - "refunded" - ], - "mappedType": "enum" - }, - "card_pan": { - "name": "card_pan", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "verify_response": { - "name": "verify_response", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "paid_at": { - "name": "paid_at", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "failed_at": { - "name": "failed_at", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "description": { - "name": "description", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - } - }, - "name": "payments", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "order_id" - ], - "composite": false, - "keyName": "payments_order_id_index", - "constraint": false, - "primary": false, - "unique": false - }, - { - "columnNames": [ - "reference_id" - ], - "composite": false, - "keyName": "payments_reference_id_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "payments_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "payments_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "payments_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "payments_order_id_foreign": { - "constraintName": "payments_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.payments", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.orders", - "updateRule": "cascade" - } - }, - "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" - }, - "order_id": { - "name": "order_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "product_id": { - "name": "product_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "quantity": { - "name": "quantity", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "unit_price": { - "name": "unit_price", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "discount": { - "name": "discount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "default": "0", - "mappedType": "decimal" - }, - "total_price": { - "name": "total_price", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - } - }, - "name": "order_items", - "schema": "public", - "indexes": [ - { - "keyName": "order_items_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "order_items_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "order_items_product_id_index", - "columnNames": [ - "product_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "order_items_order_id_index", - "columnNames": [ - "order_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "order_items_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_items_order_id_foreign": { - "constraintName": "order_items_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_items", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.orders", - "updateRule": "cascade" - }, - "order_items_product_id_foreign": { - "constraintName": "order_items_product_id_foreign", - "columnNames": [ - "product_id" - ], - "localTableName": "public.order_items", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.products", - "updateRule": "cascade" - } - }, - "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" - }, - "restaurant_id": { - "name": "restaurant_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "user_id": { - "name": "user_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "admin_id": { - "name": "admin_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "title": { - "name": "title", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "pager.created", - "order.created", - "payment.success", - "review.created", - "order.status.changed" - ], - "mappedType": "enum" - }, - "content": { - "name": "content", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "seen_at": { - "name": "seen_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "notifications", - "schema": "public", - "indexes": [ - { - "keyName": "notifications_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "notifications_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "notifications_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "notifications_restaurant_id_foreign": { - "constraintName": "notifications_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.notifications", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - }, - "notifications_user_id_foreign": { - "constraintName": "notifications_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.notifications", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "notifications_admin_id_foreign": { - "constraintName": "notifications_admin_id_foreign", - "columnNames": [ - "admin_id" - ], - "localTableName": "public.notifications", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "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" - }, - "product_id": { - "name": "product_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - } - }, - "name": "favorites", - "schema": "public", - "indexes": [ - { - "keyName": "favorites_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "favorites_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "favorites_user_id_product_id_unique", - "columnNames": [ - "user_id", - "product_id" - ], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "favorites_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "favorites_user_id_foreign": { - "constraintName": "favorites_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.favorites", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - }, - "favorites_product_id_foreign": { - "constraintName": "favorites_product_id_foreign", - "columnNames": [ - "product_id" - ], - "localTableName": "public.favorites", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.products", - "updateRule": "cascade" - } - }, - "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" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "address": { - "name": "address", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "city": { - "name": "city", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "province": { - "name": "province", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "postal_code": { - "name": "postal_code", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "latitude": { - "name": "latitude", - "type": "real", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "float" - }, - "longitude": { - "name": "longitude", - "type": "real", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "float" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - } - }, - "name": "user_addresses", - "schema": "public", - "indexes": [ - { - "keyName": "user_addresses_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "user_addresses_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "user_addresses_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "user_addresses_user_id_foreign": { - "constraintName": "user_addresses_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.user_addresses", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - } - }, - "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" - }, - "amount": { - "name": "amount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "balance": { - "name": "balance", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "credit", - "debit" - ], - "mappedType": "enum" - }, - "reason": { - "name": "reason", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "order_payment", - "order_refund", - "convert_score_to_wallet", - "withdraw", - "deposit" - ], - "mappedType": "enum" - } - }, - "name": "wallet_transactions", - "schema": "public", - "indexes": [ - { - "keyName": "wallet_transactions_created_at_index", - "columnNames": [ - "created_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "wallet_transactions_deleted_at_index", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "wallet_transactions_restaurant_id_index", - "columnNames": [ - "restaurant_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "wallet_transactions_user_id_index", - "columnNames": [ - "user_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "wallet_transactions_user_id_restaurant_id_index", - "columnNames": [ - "user_id", - "restaurant_id" - ], - "composite": true, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "wallet_transactions_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "wallet_transactions_user_id_foreign": { - "constraintName": "wallet_transactions_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.wallet_transactions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - }, - "wallet_transactions_restaurant_id_foreign": { - "constraintName": "wallet_transactions_restaurant_id_foreign", - "columnNames": [ - "restaurant_id" - ], - "localTableName": "public.wallet_transactions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.restaurants", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - } - ], - "nativeEnums": {} -} \ No newline at end of file diff --git a/database/migrations/Migration20260105085439.ts b/database/migrations/Migration20260105085439.ts deleted file mode 100644 index cfac84e..0000000 --- a/database/migrations/Migration20260105085439.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Migration } from '@mikro-orm/migrations'; - -export class Migration20260105085439 extends Migration { - - override async up(): Promise { - this.addSql(`alter table "point_transactions" drop constraint if exists "point_transactions_type_check";`); - - this.addSql(`alter table "categories" add column "order" int null;`); - - this.addSql(`alter table "point_transactions" add constraint "point_transactions_type_check" check("type" in (''));`); - } - - override async down(): Promise { - this.addSql(`create table "user_wallets" ("id" char(26) not null, "created_at" timestamptz(6) not null default now(), "updated_at" timestamptz(6) not null default now(), "deleted_at" timestamptz(6) null, "restaurant_id" char(26) not null, "user_id" char(26) not null, "wallet" int4 not null default 0, "points" int4 not null default 0, constraint "user_wallets_pkey" primary key ("id"));`); - this.addSql(`alter table "user_wallets" add constraint "unique_user_restaurant" unique ("user_id", "restaurant_id");`); - this.addSql(`create index "user_wallets_created_at_index" on "user_wallets" ("created_at");`); - this.addSql(`create index "user_wallets_deleted_at_index" on "user_wallets" ("deleted_at");`); - this.addSql(`create index "user_wallets_restaurant_id_index" on "user_wallets" ("restaurant_id");`); - this.addSql(`create index "user_wallets_user_id_index" on "user_wallets" ("user_id");`); - this.addSql(`create index "user_wallets_user_id_restaurant_id_index" on "user_wallets" ("user_id", "restaurant_id");`); - - 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 (''));`); - } - -} diff --git a/database/migrations/Migration20260106054151.ts b/database/migrations/Migration20260106054151.ts deleted file mode 100644 index 96ead46..0000000 --- a/database/migrations/Migration20260106054151.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Migration } from '@mikro-orm/migrations'; - -export class Migration20260106054151 extends Migration { - - override async up(): Promise { - this.addSql(`alter table "restaurants" alter column "subscription_id" type varchar(255) using ("subscription_id"::varchar(255));`); - this.addSql(`alter table "restaurants" alter column "subscription_id" drop not null;`); - this.addSql(`alter table "restaurants" alter column "subscription_end_date" type timestamptz using ("subscription_end_date"::timestamptz);`); - this.addSql(`alter table "restaurants" alter column "subscription_end_date" drop not null;`); - this.addSql(`alter table "restaurants" alter column "subscription_start_date" type timestamptz using ("subscription_start_date"::timestamptz);`); - this.addSql(`alter table "restaurants" alter column "subscription_start_date" drop not null;`); - } - - override async down(): Promise { - this.addSql(`alter table "restaurants" alter column "subscription_id" type varchar(255) using ("subscription_id"::varchar(255));`); - this.addSql(`alter table "restaurants" alter column "subscription_id" set not null;`); - this.addSql(`alter table "restaurants" alter column "subscription_end_date" type timestamptz using ("subscription_end_date"::timestamptz);`); - this.addSql(`alter table "restaurants" alter column "subscription_end_date" set not null;`); - this.addSql(`alter table "restaurants" alter column "subscription_start_date" type timestamptz using ("subscription_start_date"::timestamptz);`); - this.addSql(`alter table "restaurants" alter column "subscription_start_date" set not null;`); - } - -} diff --git a/database/migrations/Migration20260106192946.ts b/database/migrations/Migration20260106192946.ts deleted file mode 100644 index 3e324b4..0000000 --- a/database/migrations/Migration20260106192946.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Migration } from '@mikro-orm/migrations'; - -export class Migration20260106192946 extends Migration { - - override async up(): Promise { - this.addSql(`alter table "contacts" add column "restaurant_id" char(26) null;`); - this.addSql(`alter table "contacts" add constraint "contacts_restaurant_id_foreign" foreign key ("restaurant_id") references "restaurants" ("id") on update cascade on delete set null;`); - } - - override async down(): Promise { - this.addSql(`alter table "contacts" drop constraint "contacts_restaurant_id_foreign";`); - } - -} diff --git a/src/common/entities/base.entity.ts b/src/common/entities/base.entity.ts index 87da4e7..6f072f4 100755 --- a/src/common/entities/base.entity.ts +++ b/src/common/entities/base.entity.ts @@ -1,25 +1,15 @@ -import { Index, PrimaryKey, Property, Filter, OptionalProps } from '@mikro-orm/core'; -import { ulid } from 'ulid'; +import { Index, Property, Filter, OptionalProps } from '@mikro-orm/core'; + @Filter({ name: 'notDeleted', cond: { deletedAt: null }, default: true }) @Index({ properties: ['deletedAt'] }) @Index({ properties: ['createdAt'] }) export abstract class BaseEntity { - [OptionalProps]?: 'id' | 'createdAt' | 'updatedAt' | 'deletedAt'; - - @PrimaryKey({ type: 'string', columnType: 'char(26)' }) - id: string = ulid(); + [OptionalProps]?: 'createdAt' | 'deletedAt'; @Property({ defaultRaw: 'now()', columnType: 'timestamptz' }) createdAt: Date = new Date(); - @Property({ - onUpdate: () => new Date(), - defaultRaw: 'now()', - columnType: 'timestamptz', - }) - updatedAt: Date = new Date(); - - @Property({ nullable: true }) + @Property({ nullable: true, columnType: 'timestamptz' }) deletedAt?: Date; } diff --git a/src/modules/product/controllers/category.controller.ts b/src/modules/product/controllers/category.controller.ts deleted file mode 100644 index 9360e58..0000000 --- a/src/modules/product/controllers/category.controller.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; -import { CategoryService } from '../providers/category.service'; -import { CreateCategoryDto } from '../dto/create-category.dto'; -import { UpdateCategoryDto } from '../dto/update-category.dto'; -import { - ApiTags, - ApiOperation, - ApiCreatedResponse, - ApiOkResponse, - ApiNotFoundResponse, - ApiParam, - ApiBody, - ApiBearerAuth, - ApiHeader, -} from '@nestjs/swagger'; -import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard'; -import { UseGuards } from '@nestjs/common'; -import { RestId } from 'src/common/decorators'; -import { Permission } from 'src/common/enums/permission.enum'; -import { Permissions } from 'src/common/decorators/permissions.decorator'; -import { API_HEADER_SLUG } from 'src/common/constants'; - -@ApiTags('category') -@Controller() -export class CategoryController { - constructor(private readonly categoryService: CategoryService) { } - - @Get('public/categories/restaurant/:slug') - @ApiOperation({ summary: 'Get all categories by restaurant slug' }) - @ApiHeader(API_HEADER_SLUG) - @ApiParam({ name: 'slug', required: true, description: 'Restaurant Slug' }) - @ApiOkResponse({ description: 'List of all categories for the restaurant' }) - findAllByRestaurant(@Param('slug') slug: string) { - return this.categoryService.findAllByRestaurant(slug); - } - - /*** Admin ***/ - - @ApiOperation({ summary: 'Create category' }) - @ApiBody({ type: CreateCategoryDto }) - @Permissions(Permission.MANAGE_CATEGORIES) - @UseGuards(AdminAuthGuard) - @ApiBearerAuth() - @Post('admin/categories') - create(@Body() dto: CreateCategoryDto, @RestId() restId: string) { - return this.categoryService.create(restId, dto); - } - @Permissions(Permission.MANAGE_CATEGORIES) - @ApiOperation({ summary: 'my restaurant categories' }) - @UseGuards(AdminAuthGuard) - @ApiBearerAuth() - @Get('admin/categories') - findAll(@RestId() restId: string) { - return this.categoryService.findAllByRestaurantId(restId); - } - - @Permissions(Permission.MANAGE_CATEGORIES) - @UseGuards(AdminAuthGuard) - @ApiBearerAuth() - @Get('admin/categories/:id') - @ApiOperation({ summary: 'Get category' }) - @ApiParam({ name: 'id', required: true, type: String }) - findOne(@Param('id') id: string, @RestId() restId: string) { - return this.categoryService.findOne(restId, id); - } - - @UseGuards(AdminAuthGuard) - @ApiBearerAuth() - @Permissions(Permission.MANAGE_CATEGORIES) - @Patch('admin/categories/:id') - @ApiOperation({ summary: 'Update category' }) - @ApiParam({ name: 'id' }) - @ApiBody({ type: UpdateCategoryDto }) - update(@Param('id') id: string, @Body() dto: UpdateCategoryDto, @RestId() restId: string) { - return this.categoryService.update(restId, id, dto); - } - - @UseGuards(AdminAuthGuard) - @ApiBearerAuth() - @Permissions(Permission.MANAGE_CATEGORIES) - @Delete('admin/categories/:id') - @ApiOperation({ summary: 'Delete category' }) - @ApiParam({ name: 'id' }) - @ApiOkResponse({ description: 'Deleted' }) - remove(@Param('id') id: string, @RestId() restId: string) { - return this.categoryService.remove(restId, id); - } - -} diff --git a/src/modules/product/crone/product.crone.ts b/src/modules/product/crone/product.crone.ts deleted file mode 100644 index 99e3066..0000000 --- a/src/modules/product/crone/product.crone.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Injectable, Logger } from '@nestjs/common'; -import { Cron } from '@nestjs/schedule'; -import { EntityManager } from '@mikro-orm/postgresql'; -import { Inventory } from '../../inventory/entities/inventory.entity'; - -@Injectable() -export class productStockCrone { - private readonly logger = new Logger(productStockCrone.name); - - constructor(private readonly em: EntityManager) { } - - // run every day at 00:03 - @Cron('3 0 * * *', { - name: 'resetAvailableStock', - timeZone: 'UTC', - }) - async handleCron() { - try { - this.logger.debug('Starting daily inventory reset (availableStock = totalStock)'); - - const inventories = await this.em.find(Inventory, {}); - if (!inventories || inventories.length === 0) { - this.logger.debug('No inventory records found to reset'); - return; - } - - this.logger.log(`Resetting available stock for ${inventories.length} inventory records`); - - await this.em.transactional(async em => { - for (const inv of inventories) { - // reload inside transaction to avoid concurrency issues - const record = await em.findOne(Inventory, { id: inv.id }); - if (!record) continue; - record.availableStock = record.totalStock; - em.persist(record); - } - await em.flush(); - }); - - this.logger.log('Daily inventory reset completed'); - } catch (err) { - this.logger.error(`productStockCrone failed: ${err?.message}`, err); - } - } -} diff --git a/src/modules/product/entities/attribute-value.entity.ts b/src/modules/product/entities/attribute-value.entity.ts new file mode 100644 index 0000000..99a8124 --- /dev/null +++ b/src/modules/product/entities/attribute-value.entity.ts @@ -0,0 +1,22 @@ +import { Entity, Property, ManyToOne } from '@mikro-orm/core'; +import { BaseEntity } from '../../../common/entities/base.entity'; +import { Attribute } from './attribute.entity'; + +@Entity({ tableName: 'attribute_values' }) +export class AttributeValue extends BaseEntity { + @Property({ primary: true }) + id: bigint; + + @Property() + value: string; + + @ManyToOne(() => Attribute) + attribute: Attribute; + + @Property({ type: 'bigint' }) + attributeId: bigint; + + @Property({ type: 'int', nullable: true }) + sortOrder?: number; + +} diff --git a/src/modules/product/entities/attribute.entity.ts b/src/modules/product/entities/attribute.entity.ts new file mode 100644 index 0000000..094a941 --- /dev/null +++ b/src/modules/product/entities/attribute.entity.ts @@ -0,0 +1,19 @@ +import { Entity, Enum, Property } from '@mikro-orm/core'; +import { BaseEntity } from '../../../common/entities/base.entity'; +import { AttributeType } from '../interface/product.interface'; + +@Entity({ tableName: 'attributes' }) +export class Attribute extends BaseEntity { + @Property({ primary: true }) + id: bigint; + + @Property() + name: string; + + @Enum() + type: AttributeType; + + @Property({ type: 'boolean', default: false }) + isRequired: boolean = false; + +} diff --git a/src/modules/product/entities/category.entity.ts b/src/modules/product/entities/category.entity.ts deleted file mode 100644 index 3322b5d..0000000 --- a/src/modules/product/entities/category.entity.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Entity, Index, Property, Collection, OneToMany, ManyToOne } from '@mikro-orm/core'; -import { product } from './product.entity'; -import { BaseEntity } from '../../../common/entities/base.entity'; -import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity'; - -@Entity({ tableName: 'categories' }) -@Index({ properties: ['restaurant', 'isActive'] }) -@Index({ properties: ['isActive'] }) -export class Category extends BaseEntity { - @Property() - title!: string; - - @OneToMany(() => product, product => product.category) - products = new Collection(this); - - @Property({ default: true }) - isActive: boolean = true; - - @ManyToOne(() => Restaurant) - restaurant!: Restaurant; - - @Property({ nullable: true }) - avatarUrl?: string; - - @Property({ type: 'int', nullable: true }) - order?: number; -} diff --git a/src/modules/product/entities/favorite.entity.ts b/src/modules/product/entities/favorite.entity.ts deleted file mode 100644 index 0cedb48..0000000 --- a/src/modules/product/entities/favorite.entity.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Entity, ManyToOne, Unique } from '@mikro-orm/core'; -import { BaseEntity } from '../../../common/entities/base.entity'; -import { User } from '../../user/entities/user.entity'; -import { product } from '../../products/entities/product.entity'; - -@Entity({ tableName: 'favorites' }) -@Unique({ properties: ['user', 'product'] }) -export class Favorite extends BaseEntity { - @ManyToOne(() => User) - user: User; - - @ManyToOne(() => product) - product: product; -} diff --git a/src/modules/product/entities/food.entity.ts b/src/modules/product/entities/food.entity.ts deleted file mode 100644 index 50a5fbe..0000000 --- a/src/modules/product/entities/food.entity.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Entity, Property } from '@mikro-orm/core'; -import { BaseEntity } from '../../../common/entities/base.entity'; - - -@Entity({ tableName: 'products' }) -export class product extends BaseEntity { - - - @Property({ nullable: true }) - title?: string; - - @Property({ type: 'text', nullable: true }) - linkUrl?: string; - - - @Property({ type: 'boolean', default: true }) - isActive: boolean = true; - - @Property({ type: 'json', nullable: true }) - images?: string[]; - - -} diff --git a/src/modules/product/entities/product.entity.ts b/src/modules/product/entities/product.entity.ts index ee86bdc..1ba716e 100644 --- a/src/modules/product/entities/product.entity.ts +++ b/src/modules/product/entities/product.entity.ts @@ -4,20 +4,19 @@ import { BaseEntity } from '../../../common/entities/base.entity'; @Entity({ tableName: 'products' }) export class product extends BaseEntity { + @Property({ primary: true }) + id: bigint - - @Property({ nullable: true }) - title?: string; + @Property() + title: string; @Property({ type: 'text', nullable: true }) linkUrl?: string; - @Property({ type: 'boolean', default: true }) isActive: boolean = true; @Property({ type: 'json', nullable: true }) images?: string[]; - } diff --git a/src/modules/product/interface/product.interface.ts b/src/modules/product/interface/product.interface.ts index 033e3ca..ebcfe98 100644 --- a/src/modules/product/interface/product.interface.ts +++ b/src/modules/product/interface/product.interface.ts @@ -1,6 +1,7 @@ -export enum MealType { - BREAKFAST = 'breakfast', - LUNCH = 'lunch', - DINNER = 'dinner', - SNACK = 'snack', -} +export enum AttributeType{ + SELECT='select', + TEXT='text', + NUMBER='number', + CHECKBOX='checkbox', + BOOLEAN='boolean', +} diff --git a/src/modules/product/product.module.ts b/src/modules/product/product.module.ts index b00f193..57adb23 100644 --- a/src/modules/product/product.module.ts +++ b/src/modules/product/product.module.ts @@ -2,14 +2,12 @@ import { Module } from '@nestjs/common'; import { productService } from './providers/product.service'; import { productStockCrone } from './crone/product.crone'; import { productController } from './controllers/product.controller'; -import { CategoryController } from './controllers/category.controller'; -import { CategoryService } from './providers/category.service'; import { productRepository } from './repositories/product.repository'; -import { CategoryRepository } from './repositories/category.repository'; import { MikroOrmModule } from '@mikro-orm/nestjs'; import { Category } from './entities/category.entity'; import { product } from './entities/product.entity'; -import { RestaurantsModule } from '../restaurants/restaurants.module'; +import { Attribute } from './entities/attribute.entity'; +import { AttributeValue } from './entities/attribute-value.entity'; import { AuthModule } from '../auth/auth.module'; import { JwtModule } from '@nestjs/jwt'; import { UtilsModule } from '../util/utils.module'; @@ -17,14 +15,13 @@ import { Favorite } from './entities/favorite.entity'; @Module({ imports: [ - MikroOrmModule.forFeature([product, Category, Favorite]), - RestaurantsModule, + MikroOrmModule.forFeature([product, Category, Favorite, Attribute, AttributeValue]), AuthModule, JwtModule, UtilsModule, ], - controllers: [productController, CategoryController], - providers: [productService, CategoryService, productRepository, CategoryRepository, productStockCrone], - exports: [productRepository, CategoryRepository], + controllers: [productController,], + providers: [productService, productRepository, productStockCrone], + exports: [productRepository,], }) export class productModule { } diff --git a/src/modules/product/providers/category.service.ts b/src/modules/product/providers/category.service.ts deleted file mode 100644 index adee964..0000000 --- a/src/modules/product/providers/category.service.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { Injectable, NotFoundException } from '@nestjs/common'; -import { CreateCategoryDto } from '../dto/create-category.dto'; -import { UpdateCategoryDto } from '../dto/update-category.dto'; -import { CategoryRepository } from '../repositories/category.repository'; -import { EntityManager } from '@mikro-orm/postgresql'; -import { RequiredEntityData } from '@mikro-orm/core'; -import { Category } from '../entities/category.entity'; -import { CategoryMessage, RestMessage } from 'src/common/enums/message.enum'; -import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity'; - -@Injectable() -export class CategoryService { - constructor( - private readonly categoryRepository: CategoryRepository, - private readonly em: EntityManager, - ) { } - - async create(restId: string, dto: CreateCategoryDto): Promise { - const restaurant = await this.em.findOne(Restaurant, { id: restId }); - if (!restaurant) { - throw new NotFoundException(RestMessage.NOT_FOUND); - } - const data: RequiredEntityData = { - title: dto.title, - isActive: dto.isActive ?? true, - restaurant: restaurant, - avatarUrl: dto.avatarUrl, - }; - - const category = this.categoryRepository.create(data); - await this.em.persistAndFlush(category); - return category; - } - - async findAllByRestaurant(slug: string): Promise { - const restaurant = await this.em.findOne(Restaurant, { slug }); - if (!restaurant || !restaurant.id) { - throw new NotFoundException(RestMessage.NOT_FOUND); - } - return this.categoryRepository.find({ restaurant: restaurant, isActive: true }); - } - - async findAllByRestaurantId(restId: string): Promise { - return this.categoryRepository.find({ restaurant: { id: restId } }); - } - - // async findAll(opts?: { restId?: string; isActive?: boolean }): Promise { - // const where: FilterQuery = {}; - // if (opts?.restId) where.restId = opts.restId; - // if (opts && typeof opts.isActive === 'boolean') where.isActive = opts.isActive; - // const cats = await this.categoryRepository.find(where, { populate: ['products'] }); - - // // Return plain objects to avoid circular references during JSON serialization - // return cats.map(cat => ({ - // id: cat.id, - // title: cat.title, - // isActive: cat.isActive, - // restId: cat.restId, - // avatarUrl: cat.avatarUrl, - // createdAt: cat.createdAt, - // updatedAt: cat.updatedAt, - // products: cat.products.getItems().map(f => ({ id: f.id, title: f.title })), - // })) as unknown as Category[]; - // } - - async findOne(restId: string, id: string): Promise { - const cat = await this.categoryRepository.findOne({ id, restaurant: { id: restId } }, { populate: ['products'] }); - if (!cat) throw new NotFoundException(CategoryMessage.NOT_FOUND); - - return { - id: cat.id, - title: cat.title, - isActive: cat.isActive, - restaurant: cat.restaurant, - avatarUrl: cat.avatarUrl, - createdAt: cat.createdAt, - updatedAt: cat.updatedAt, - products: cat.products.getItems().map(f => ({ id: f.id, title: f.title })), - } as unknown as Category; - } - - async findRestaurantCategories(restId: string): Promise { - const cat = await this.categoryRepository.findOne({ restaurant: { id: restId } }, { populate: ['products'] }); - if (!cat) throw new NotFoundException(CategoryMessage.NOT_FOUND); - - return { - id: cat.id, - title: cat.title, - isActive: cat.isActive, - restaurant: cat.restaurant, - avatarUrl: cat.avatarUrl, - createdAt: cat.createdAt, - updatedAt: cat.updatedAt, - } as unknown as Category; - } - - async update(restId: string, id: string, dto: UpdateCategoryDto): Promise { - const cat = await this.categoryRepository.findOne({ id, restaurant: { id: restId } }); - if (!cat) throw new NotFoundException(CategoryMessage.NOT_FOUND); - this.em.assign(cat, dto); - await this.em.persistAndFlush(cat); - return cat; - } - - async remove(restId: string, id: string): Promise { - const cat = await this.categoryRepository.findOne({ id, restaurant: { id: restId } }); - if (!cat) throw new NotFoundException(CategoryMessage.NOT_FOUND); - cat.deletedAt = new Date(); - await this.em.persistAndFlush(cat); - } -} diff --git a/src/modules/product/providers/product.service.ts b/src/modules/product/providers/product.service.ts index c9b9a05..05142c8 100644 --- a/src/modules/product/providers/product.service.ts +++ b/src/modules/product/providers/product.service.ts @@ -2,29 +2,19 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { CreateproductDto } from '../dto/create-product.dto'; import { FindproductsDto } from '../dto/find-products.dto'; import { productRepository } from '../repositories/product.repository'; -import { CategoryRepository } from '../repositories/category.repository'; import { EntityManager } from '@mikro-orm/postgresql'; import { RequiredEntityData, FilterQuery } from '@mikro-orm/core'; import { product } from '../entities/product.entity'; import { CategoryMessage, productMessage, RestMessage } from 'src/common/enums/message.enum'; -import { RestRepository } from 'src/modules/restaurants/repositories/rest.repository'; import { CacheService } from '../../util/cache.service'; -import { Favorite } from '../entities/favorite.entity'; -import { MealType } from '../interface/product.interface'; -import { Inventory } from 'src/modules/inventory/entities/inventory.entity'; @Injectable() export class productService { - private readonly productS_BY_RESTAURANT_CACHE_KEY_PREFIX = 'products:restaurant:'; - private readonly productS_CACHE_TTL = 600; // 10 minutes in seconds constructor( private readonly productRepository: productRepository, - private readonly categoryRepository: CategoryRepository, - private readonly restRepository: RestRepository, private readonly em: EntityManager, - private readonly cacheService: CacheService, - ) { } + ) { } async create(restId: string, createproductDto: CreateproductDto) { const { categoryId, dailyStock = 0, ...rest } = createproductDto; diff --git a/src/modules/product/repositories/category.repository.ts b/src/modules/product/repositories/category.repository.ts deleted file mode 100644 index b3028b3..0000000 --- a/src/modules/product/repositories/category.repository.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { EntityManager, EntityRepository } from '@mikro-orm/postgresql'; -import { Category } from '../entities/category.entity'; - -@Injectable() -export class CategoryRepository extends EntityRepository { - constructor(readonly em: EntityManager) { - super(em, Category); - } -} diff --git a/src/seeders/data/categories.data.ts b/src/seeders/data/categories.data.ts index 479663f..ad9a436 100644 --- a/src/seeders/data/categories.data.ts +++ b/src/seeders/data/categories.data.ts @@ -1,3 +1,4 @@ + export interface CategoryData { title: string; restaurantSlug: string;