From 2555cc12d1d8b342ec0525e930f0a87c42e5e4e1 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Tue, 17 Feb 2026 15:44:21 +0330 Subject: [PATCH] fix: bill --- database/migrations/.snapshot-dzone-db.json | 6676 +++++++++++++++++ ...igration20260217121029_meterageREquired.ts | 13 + package.json | 4 +- pnpm-lock.yaml | 165 + src/modules/bills/bills.controller.ts | 3 + src/modules/bills/bills.module.ts | 9 +- src/modules/bills/bills.service.ts | 65 +- .../companies/DTO/create-company.dto.ts | 4 +- .../companies/entities/company.entity.ts | 4 +- 9 files changed, 6910 insertions(+), 33 deletions(-) create mode 100644 database/migrations/.snapshot-dzone-db.json create mode 100644 database/migrations/Migration20260217121029_meterageREquired.ts diff --git a/database/migrations/.snapshot-dzone-db.json b/database/migrations/.snapshot-dzone-db.json new file mode 100644 index 0000000..7c6ace6 --- /dev/null +++ b/database/migrations/.snapshot-dzone-db.json @@ -0,0 +1,6676 @@ +{ + "namespaces": [ + "public" + ], + "name": "public", + "tables": [ + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "danak_subscription_id": { + "name": "danak_subscription_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "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" + }, + "domain": { + "name": "domain", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 255, + "mappedType": "string" + }, + "is_domain_verified": { + "name": "is_domain_verified", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "domain_verification_token": { + "name": "domain_verification_token", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 255, + "mappedType": "string" + }, + "domain_verified_at": { + "name": "domain_verified_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "logo_url": { + "name": "logo_url", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 255, + "mappedType": "string" + }, + "zarinpal_merchant_id": { + "name": "zarinpal_merchant_id", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 255, + "mappedType": "string" + } + }, + "name": "business", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "danak_subscription_id" + ], + "composite": false, + "keyName": "business_danak_subscription_id_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "keyName": "business_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": {}, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "type": { + "name": "type", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "enumItems": [ + "monthly_charge", + "water_bill" + ], + "mappedType": "enum" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "bill", + "schema": "public", + "indexes": [ + { + "keyName": "bill_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "bill_business_id_foreign": { + "constraintName": "bill_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.bill", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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(100)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 100, + "mappedType": "string" + }, + "content": { + "name": "content", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "publish_at": { + "name": "publish_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "default": "null", + "mappedType": "datetime" + }, + "is_important": { + "name": "is_important", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + } + }, + "name": "announcement", + "schema": "public", + "indexes": [ + { + "keyName": "announcement_is_public_created_at_index", + "columnNames": [ + "is_public", + "created_at" + ], + "composite": true, + "constraint": false, + "primary": false, + "unique": false + }, + { + "keyName": "announcement_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "announcement_business_id_foreign": { + "constraintName": "announcement_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.announcement", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "danak_user_id": { + "name": "danak_user_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "full_name": { + "name": "full_name", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "email": { + "name": "email", + "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": false, + "length": 255, + "mappedType": "string" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "business_staff", + "schema": "public", + "indexes": [ + { + "keyName": "business_staff_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "business_staff_business_id_foreign": { + "constraintName": "business_staff_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.business_staff", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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" + }, + "icon_url": { + "name": "icon_url", + "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" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "industry", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "title" + ], + "composite": false, + "keyName": "industry_title_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "keyName": "industry_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "industry_business_id_foreign": { + "constraintName": "industry_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.industry", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "restrict", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "enumItems": [ + "zarinpal" + ], + "mappedType": "enum" + }, + "name_fa": { + "name": "name_fa", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "logo_url": { + "name": "logo_url", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "true", + "mappedType": "boolean" + }, + "description": { + "name": "description", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + } + }, + "name": "payment_gateway", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "name" + ], + "composite": false, + "keyName": "payment_gateway_name_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "keyName": "payment_gateway_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": {}, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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": "role_enum", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "role_enum", + "default": "'USER'", + "enumItems": [ + "ADMIN", + "USER" + ], + "mappedType": "enum" + } + }, + "name": "role", + "schema": "public", + "indexes": [ + { + "keyName": "role_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": {}, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "description": { + "name": "description", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 255, + "mappedType": "string" + }, + "image_url": { + "name": "image_url", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "link": { + "name": "link", + "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": false, + "default": "0", + "mappedType": "integer" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "true", + "mappedType": "boolean" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "slider", + "schema": "public", + "indexes": [ + { + "keyName": "slider_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "slider_business_id_foreign": { + "constraintName": "slider_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.slider", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "restrict", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "description": { + "name": "description", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "true", + "mappedType": "boolean" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "ticket_category", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "title" + ], + "composite": false, + "keyName": "ticket_category_title_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "keyName": "ticket_category_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "ticket_category_business_id_foreign": { + "constraintName": "ticket_category_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.ticket_category", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "last_name": { + "name": "last_name", + "type": "varchar(200)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 200, + "mappedType": "string" + }, + "email": { + "name": "email", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 150, + "mappedType": "string" + }, + "phone": { + "name": "phone", + "type": "varchar(11)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 11, + "mappedType": "string" + }, + "user_name": { + "name": "user_name", + "type": "varchar(50)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 50, + "mappedType": "string" + }, + "password": { + "name": "password", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "birth_date": { + "name": "birth_date", + "type": "varchar(12)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 12, + "mappedType": "string" + }, + "national_code": { + "name": "national_code", + "type": "varchar(100)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 100, + "mappedType": "string" + }, + "profile_pic": { + "name": "profile_pic", + "type": "varchar(100)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 100, + "mappedType": "string" + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "role_id": { + "name": "role_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "user", + "schema": "public", + "indexes": [ + { + "keyName": "user_phone_business_id_user_name_national_code_unique", + "columnNames": [ + "phone", + "business_id", + "user_name", + "national_code" + ], + "composite": true, + "constraint": true, + "primary": false, + "unique": true + }, + { + "keyName": "user_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "user_role_id_foreign": { + "constraintName": "user_role_id_foreign", + "columnNames": [ + "role_id" + ], + "localTableName": "public.user", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.role", + "deleteRule": "restrict", + "updateRule": "cascade" + }, + "user_business_id_foreign": { + "constraintName": "user_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.user", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "restrict", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "token": { + "name": "token", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "refresh_token", + "schema": "public", + "indexes": [ + { + "keyName": "refresh_token_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "refresh_token_user_id_foreign": { + "constraintName": "refresh_token_user_id_foreign", + "columnNames": [ + "user_id" + ], + "localTableName": "public.refresh_token", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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(250)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 250, + "mappedType": "string" + }, + "message": { + "name": "message", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "type": { + "name": "type", + "type": "notif_type", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "notif_type", + "enumItems": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ], + "mappedType": "enum" + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "recipient_id": { + "name": "recipient_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "notification", + "schema": "public", + "indexes": [ + { + "keyName": "notification_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "notification_recipient_id_foreign": { + "constraintName": "notification_recipient_id_foreign", + "columnNames": [ + "recipient_id" + ], + "localTableName": "public.notification", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "numeric_id": { + "name": "numeric_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "title": { + "name": "title", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "content": { + "name": "content", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "criticism", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "title" + ], + "composite": false, + "keyName": "criticism_title_index", + "constraint": false, + "primary": false, + "unique": false + }, + { + "keyName": "criticism_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "criticism_user_id_foreign": { + "constraintName": "criticism_user_id_foreign", + "columnNames": [ + "user_id" + ], + "localTableName": "public.criticism", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "criticism_business_id_foreign": { + "constraintName": "criticism_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.criticism", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "file_url": { + "name": "file_url", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "criticism_id": { + "name": "criticism_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "criticism_file", + "schema": "public", + "indexes": [ + { + "keyName": "criticism_file_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "criticism_file_criticism_id_foreign": { + "constraintName": "criticism_file_criticism_id_foreign", + "columnNames": [ + "criticism_id" + ], + "localTableName": "public.criticism_file", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.criticism", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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" + }, + "chief_executive_officer": { + "name": "chief_executive_officer", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "email": { + "name": "email", + "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": false, + "length": 255, + "mappedType": "string" + }, + "identification_number": { + "name": "identification_number", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "date_of_establishment": { + "name": "date_of_establishment", + "type": "date", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 0, + "mappedType": "date" + }, + "address": { + "name": "address", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "map_address_link": { + "name": "map_address_link", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "description": { + "name": "description", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "website_url": { + "name": "website_url", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "profile_image_url": { + "name": "profile_image_url", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "cover_image_url": { + "name": "cover_image_url", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 255, + "mappedType": "string" + }, + "metrage": { + "name": "metrage", + "type": "int", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "true", + "mappedType": "boolean" + }, + "status": { + "name": "status", + "type": "company_status", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "company_status", + "enumItems": [ + "APPROVED", + "PENDING", + "REJECTED" + ], + "mappedType": "enum" + }, + "industry_id": { + "name": "industry_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "company", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "name" + ], + "composite": false, + "keyName": "company_name_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "columnNames": [ + "email" + ], + "composite": false, + "keyName": "company_email_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "columnNames": [ + "phone" + ], + "composite": false, + "keyName": "company_phone_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "columnNames": [ + "identification_number" + ], + "composite": false, + "keyName": "company_identification_number_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "columnNames": [ + "user_id" + ], + "composite": false, + "keyName": "company_user_id_unique", + "constraint": true, + "primary": false, + "unique": true + }, + { + "keyName": "company_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "company_industry_id_foreign": { + "constraintName": "company_industry_id_foreign", + "columnNames": [ + "industry_id" + ], + "localTableName": "public.company", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.industry", + "deleteRule": "restrict", + "updateRule": "cascade" + }, + "company_business_id_foreign": { + "constraintName": "company_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.company", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "restrict", + "updateRule": "cascade" + }, + "company_user_id_foreign": { + "constraintName": "company_user_id_foreign", + "columnNames": [ + "user_id" + ], + "localTableName": "public.company", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "numeric_id": { + "name": "numeric_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "subject": { + "name": "subject", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "status": { + "name": "status", + "type": "ticket_status", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "ticket_status", + "default": "'PENDING'", + "enumItems": [ + "PENDING", + "ANSWERED", + "CLOSED" + ], + "mappedType": "enum" + }, + "priority": { + "name": "priority", + "type": "ticket_priority", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "ticket_priority", + "enumItems": [ + "LOW", + "MEDIUM", + "HIGH" + ], + "mappedType": "enum" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "uuid" + }, + "assigned_to_id": { + "name": "assigned_to_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "uuid" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "uuid" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "ticket", + "schema": "public", + "indexes": [ + { + "keyName": "ticket_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "ticket_company_id_foreign": { + "constraintName": "ticket_company_id_foreign", + "columnNames": [ + "company_id" + ], + "localTableName": "public.ticket", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.company", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "ticket_assigned_to_id_foreign": { + "constraintName": "ticket_assigned_to_id_foreign", + "columnNames": [ + "assigned_to_id" + ], + "localTableName": "public.ticket", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business_staff", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "ticket_user_id_foreign": { + "constraintName": "ticket_user_id_foreign", + "columnNames": [ + "user_id" + ], + "localTableName": "public.ticket", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "ticket_category_id_foreign": { + "constraintName": "ticket_category_id_foreign", + "columnNames": [ + "category_id" + ], + "localTableName": "public.ticket", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.ticket_category", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "ticket_business_id_foreign": { + "constraintName": "ticket_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.ticket", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "content": { + "name": "content", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "ticket_id": { + "name": "ticket_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "uuid" + }, + "external_author_id": { + "name": "external_author_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "uuid" + } + }, + "name": "ticket_message", + "schema": "public", + "indexes": [ + { + "keyName": "ticket_message_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "ticket_message_ticket_id_foreign": { + "constraintName": "ticket_message_ticket_id_foreign", + "columnNames": [ + "ticket_id" + ], + "localTableName": "public.ticket_message", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.ticket", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "ticket_message_author_id_foreign": { + "constraintName": "ticket_message_author_id_foreign", + "columnNames": [ + "author_id" + ], + "localTableName": "public.ticket_message", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "ticket_message_external_author_id_foreign": { + "constraintName": "ticket_message_external_author_id_foreign", + "columnNames": [ + "external_author_id" + ], + "localTableName": "public.ticket_message", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business_staff", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "attachment_url": { + "name": "attachment_url", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 150, + "mappedType": "string" + }, + "ticket_message_id": { + "name": "ticket_message_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "ticket_message_attachment", + "schema": "public", + "indexes": [ + { + "keyName": "ticket_message_attachment_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "ticket_message_attachment_ticket_message_id_foreign": { + "constraintName": "ticket_message_attachment_ticket_message_id_foreign", + "columnNames": [ + "ticket_message_id" + ], + "localTableName": "public.ticket_message_attachment", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.ticket_message", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "numeric_id": { + "name": "numeric_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "total_price": { + "name": "total_price", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + }, + "original_price": { + "name": "original_price", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + }, + "status": { + "name": "status", + "type": "invoice_status", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "invoice_status", + "default": "'PENDING'", + "enumItems": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ], + "mappedType": "enum" + }, + "due_date": { + "name": "due_date", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "mappedType": "datetime" + }, + "paid_at": { + "name": "paid_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "tax": { + "name": "tax", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + }, + "late_fee": { + "name": "late_fee", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + }, + "is_recurring": { + "name": "is_recurring", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "recurring_period": { + "name": "recurring_period", + "type": "smallint", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "enum" + }, + "max_recurring_cycles": { + "name": "max_recurring_cycles", + "type": "int", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "integer" + }, + "current_recurring_cycle": { + "name": "current_recurring_cycle", + "type": "int", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "integer" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "bill_id": { + "name": "bill_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "uuid" + } + }, + "name": "invoice", + "schema": "public", + "indexes": [ + { + "keyName": "invoice_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "invoice_company_id_foreign": { + "constraintName": "invoice_company_id_foreign", + "columnNames": [ + "company_id" + ], + "localTableName": "public.invoice", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.company", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "invoice_business_id_foreign": { + "constraintName": "invoice_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.invoice", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "invoice_bill_id_foreign": { + "constraintName": "invoice_bill_id_foreign", + "columnNames": [ + "bill_id" + ], + "localTableName": "public.invoice", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.bill", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "amount": { + "name": "amount", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + }, + "reference": { + "name": "reference", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "transaction_id": { + "name": "transaction_id", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 150, + "mappedType": "string" + }, + "status": { + "name": "status", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "'PENDING'", + "enumItems": [ + "PENDING", + "COMPLETED", + "FAILED", + "CANCELLED" + ], + "mappedType": "enum" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "payment_gateway_id": { + "name": "payment_gateway_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "business_id": { + "name": "business_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "payment", + "schema": "public", + "indexes": [ + { + "keyName": "payment_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "payment_user_id_foreign": { + "constraintName": "payment_user_id_foreign", + "columnNames": [ + "user_id" + ], + "localTableName": "public.payment", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "payment_payment_gateway_id_foreign": { + "constraintName": "payment_payment_gateway_id_foreign", + "columnNames": [ + "payment_gateway_id" + ], + "localTableName": "public.payment", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.payment_gateway", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "payment_business_id_foreign": { + "constraintName": "payment_business_id_foreign", + "columnNames": [ + "business_id" + ], + "localTableName": "public.payment", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.business", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "payment_invoice_id_foreign": { + "constraintName": "payment_invoice_id_foreign", + "columnNames": [ + "invoice_id" + ], + "localTableName": "public.payment", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.invoice", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "name": { + "name": "name", + "type": "varchar(150)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 150, + "mappedType": "string" + }, + "count": { + "name": "count", + "type": "int", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "discount": { + "name": "discount", + "type": "numeric(16,2)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + }, + "unit_price": { + "name": "unit_price", + "type": "numeric(16,2)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + }, + "total_price": { + "name": "total_price", + "type": "numeric(16,2)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "precision": 16, + "scale": 2, + "mappedType": "decimal" + } + }, + "name": "invoice_item", + "schema": "public", + "indexes": [ + { + "keyName": "invoice_item_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "invoice_item_invoice_id_foreign": { + "constraintName": "invoice_item_invoice_id_foreign", + "columnNames": [ + "invoice_id" + ], + "localTableName": "public.invoice_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.invoice", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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(250)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 250, + "mappedType": "string" + }, + "image_url": { + "name": "image_url", + "type": "varchar(250)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 250, + "mappedType": "string" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "company_service", + "schema": "public", + "indexes": [ + { + "keyName": "company_service_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "company_service_company_id_foreign": { + "constraintName": "company_service_company_id_foreign", + "columnNames": [ + "company_id" + ], + "localTableName": "public.company_service", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.company", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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(250)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 250, + "mappedType": "string" + }, + "image_url": { + "name": "image_url", + "type": "varchar(250)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 250, + "mappedType": "string" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + } + }, + "name": "company_product", + "schema": "public", + "indexes": [ + { + "keyName": "company_product_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "company_product_company_id_foreign": { + "constraintName": "company_product_company_id_foreign", + "columnNames": [ + "company_id" + ], + "localTableName": "public.company_product", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.company", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "status": { + "name": "status", + "type": "chat_session_status", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "chat_session_status", + "default": "'active'", + "enumItems": [ + "active", + "closed", + "archived" + ], + "mappedType": "enum" + }, + "context": { + "name": "context", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "chat_session", + "schema": "public", + "indexes": [ + { + "keyName": "chat_session_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "chat_session_user_id_foreign": { + "constraintName": "chat_session_user_id_foreign", + "columnNames": [ + "user_id" + ], + "localTableName": "public.chat_session", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "content": { + "name": "content", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "type": { + "name": "type", + "type": "message_type", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "message_type", + "enumItems": [ + "user", + "bot", + "system" + ], + "mappedType": "enum" + }, + "status": { + "name": "status", + "type": "message_status", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "nativeEnumName": "message_status", + "default": "'sent'", + "enumItems": [ + "sent", + "delivered", + "read", + "failed" + ], + "mappedType": "enum" + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "sender_id": { + "name": "sender_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "uuid" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "response_to_id": { + "name": "response_to_id", + "type": "varchar(255)", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 255, + "mappedType": "string" + }, + "tokens_used": { + "name": "tokens_used", + "type": "int", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "integer" + } + }, + "name": "chat_message", + "schema": "public", + "indexes": [ + { + "keyName": "chat_message_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "chat_message_session_id_foreign": { + "constraintName": "chat_message_session_id_foreign", + "columnNames": [ + "session_id" + ], + "localTableName": "public.chat_message", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.chat_session", + "updateRule": "cascade" + }, + "chat_message_sender_id_foreign": { + "constraintName": "chat_message_sender_id_foreign", + "columnNames": [ + "sender_id" + ], + "localTableName": "public.chat_message", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "set null", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "current_timestamp", + "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": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "announcement_id": { + "name": "announcement_id", + "type": "uuid", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "uuid" + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + } + }, + "name": "user_announcement", + "schema": "public", + "indexes": [ + { + "keyName": "user_announcement_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "constraint": true, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "user_announcement_user_id_foreign": { + "constraintName": "user_announcement_user_id_foreign", + "columnNames": [ + "user_id" + ], + "localTableName": "public.user_announcement", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.user", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "user_announcement_announcement_id_foreign": { + "constraintName": "user_announcement_announcement_id_foreign", + "columnNames": [ + "announcement_id" + ], + "localTableName": "public.user_announcement", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.announcement", + "deleteRule": "cascade", + "updateRule": "cascade" + } + }, + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } + } + ], + "nativeEnums": { + "role_enum": { + "name": "role_enum", + "schema": "public", + "items": [ + "ADMIN", + "USER" + ] + }, + "notif_type": { + "name": "notif_type", + "schema": "public", + "items": [ + "OTP", + "USER_LOGIN", + "ANNOUNCEMENT", + "WALLET_CHARGE", + "WALLET_DEDUCTION", + "BILL_INVOICE_REMINDER", + "BILL_INVOICE", + "APPROVE_INVOICE", + "CREATE_INVOICE", + "INVOICE_OVERDUE", + "CREATE_SERVICE", + "UNBLOCK_SERVICE", + "BLOCK_SERVICE", + "ANSWER_TICKET", + "CREATE_TICKET", + "ASSIGN_TICKET", + "RECURRING_INVOICE", + "PAYMENT_REMINDER", + "PAYMENT_CANCELLATION", + "NEW_CUSTOMER", + "NEW_TICKET", + "NEW_CRITICISM" + ] + }, + "company_status": { + "name": "company_status", + "schema": "public", + "items": [ + "APPROVED", + "PENDING", + "REJECTED" + ] + }, + "ticket_status": { + "name": "ticket_status", + "schema": "public", + "items": [ + "PENDING", + "ANSWERED", + "CLOSED" + ] + }, + "ticket_priority": { + "name": "ticket_priority", + "schema": "public", + "items": [ + "LOW", + "MEDIUM", + "HIGH" + ] + }, + "invoice_status": { + "name": "invoice_status", + "schema": "public", + "items": [ + "DRAFT", + "PENDING", + "WAIT_PAYMENT", + "PAID", + "ARCHIVED", + "OVERDUE" + ] + }, + "chat_session_status": { + "name": "chat_session_status", + "schema": "public", + "items": [ + "active", + "closed", + "archived" + ] + }, + "message_type": { + "name": "message_type", + "schema": "public", + "items": [ + "user", + "bot", + "system" + ] + }, + "message_status": { + "name": "message_status", + "schema": "public", + "items": [ + "sent", + "delivered", + "read", + "failed" + ] + } + } +} diff --git a/database/migrations/Migration20260217121029_meterageREquired.ts b/database/migrations/Migration20260217121029_meterageREquired.ts new file mode 100644 index 0000000..af355a9 --- /dev/null +++ b/database/migrations/Migration20260217121029_meterageREquired.ts @@ -0,0 +1,13 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20260217121029_meterageREquired extends Migration { + + override async up(): Promise { + this.addSql(`select 1`); + } + + override async down(): Promise { + this.addSql(`select 1`); + } + +} diff --git a/package.json b/package.json index c8a4196..3baca36 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "seed:run": "mikro-orm seeder:run --config=database/mikro-orm.config.ts", "seed:test-companies": "mikro-orm seeder:run --config=database/mikro-orm.config.ts -- --class=TestCompaniesSeeder", "seed:cleanup-test-companies": "mikro-orm seeder:run --config=database/mikro-orm.config.ts -- --class=CleanupTestCompaniesSeeder", - "db:dump": "node scripts/db-dump.js" + "db:dump": "node scripts/db-dump.js", + "db:restore": "node scripts/db-restore.js" }, "dependencies": { "@aws-sdk/client-s3": "^3.826.0", @@ -43,6 +44,7 @@ "@langchain/openai": "^0.5.12", "@mikro-orm/cli": "^6.4.16", "@mikro-orm/core": "^6.4.16", + "@mikro-orm/migrations": "6.4.16", "@mikro-orm/nestjs": "^6.1.1", "@mikro-orm/postgresql": "^6.4.16", "@mikro-orm/seeder": "^6.4.16", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1859441..4ef8341 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ importers: '@mikro-orm/core': specifier: ^6.4.16 version: 6.4.16 + '@mikro-orm/migrations': + specifier: 6.4.16 + version: 6.4.16(@mikro-orm/core@6.4.16)(@types/node@22.15.30)(pg@8.16.0) '@mikro-orm/nestjs': specifier: ^6.1.1 version: 6.1.1(@mikro-orm/core@6.4.16)(@nestjs/common@11.1.3(class-transformer@0.5.1)(class-validator@0.14.2)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.3) @@ -1607,6 +1610,12 @@ packages: mariadb: optional: true + '@mikro-orm/migrations@6.4.16': + resolution: {integrity: sha512-cyyI7QILGksGzUq67DxIFQ+C2+peLaVv9IlGboOl4dFFo2D7AdvKM8fL+k6ErnCZWfTidivy/+lUk0Z1R/kQDw==} + engines: {node: '>= 18.12.0'} + peerDependencies: + '@mikro-orm/core': ^6.0.0 + '@mikro-orm/nestjs@6.1.1': resolution: {integrity: sha512-aluD3eTeuCvIePDk5UBanHIhu1zAJQXqWAg47MZdHJmFkNuXn62DCXbD2c4X5TCpKW/m0zjba22ilyZ/AFG9qg==} engines: {node: '>= 18.12.0'} @@ -2047,6 +2056,25 @@ packages: '@rtsao/scc@1.1.0': resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==} + '@rushstack/node-core-library@5.13.0': + resolution: {integrity: sha512-IGVhy+JgUacAdCGXKUrRhwHMTzqhWwZUI+qEPcdzsb80heOw0QPbhhoVsoiMF7Klp8eYsp7hzpScMXmOa3Uhfg==} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + + '@rushstack/terminal@0.15.2': + resolution: {integrity: sha512-7Hmc0ysK5077R/IkLS9hYu0QuNafm+TbZbtYVzCMbeOdMjaRboLKrhryjwZSRJGJzu+TV1ON7qZHeqf58XfLpA==} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + + '@rushstack/ts-command-line@4.23.7': + resolution: {integrity: sha512-Gr9cB7DGe6uz5vq2wdr89WbVDKz0UeuFEn5H2CfWDe7JvjFFaiV15gi6mqDBTbHhHCWS7w8mF1h3BnIfUndqdA==} + '@scarf/scarf@1.4.0': resolution: {integrity: sha512-xxeapPiUXdZAE3che6f3xogoJPeZgig6omHEy1rIY5WVsB3H2BHNnZH+gHG6x91SCWyQCzWGsuL2Hh3ClO5/qQ==} @@ -2396,6 +2424,9 @@ packages: '@tybys/wasm-util@0.9.0': resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==} + '@types/argparse@1.0.38': + resolution: {integrity: sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==} + '@types/babel__core@7.20.5': resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} @@ -2856,6 +2887,14 @@ packages: resolution: {integrity: sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==} engines: {node: '>= 8.0.0'} + ajv-draft-04@1.0.0: + resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==} + peerDependencies: + ajv: ^8.5.0 + peerDependenciesMeta: + ajv: + optional: true + ajv-formats@2.1.1: resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} peerDependencies: @@ -2885,6 +2924,9 @@ packages: ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} + ajv@8.13.0: + resolution: {integrity: sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==} + ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} @@ -4292,6 +4334,10 @@ packages: resolution: {integrity: sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==} engines: {node: '>=14.14'} + fs-extra@11.3.3: + resolution: {integrity: sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==} + engines: {node: '>=14.14'} + fs-minipass@2.1.0: resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} engines: {node: '>= 8'} @@ -4625,6 +4671,10 @@ packages: resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} engines: {node: '>=6'} + import-lazy@4.0.0: + resolution: {integrity: sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==} + engines: {node: '>=8'} + import-local@3.2.0: resolution: {integrity: sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==} engines: {node: '>=8'} @@ -5047,6 +5097,9 @@ packages: resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} hasBin: true + jju@1.4.0: + resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==} + js-beautify@1.15.4: resolution: {integrity: sha512-9/KXeZUKKJwqCXUdBxFJ3vPh467OCckSBmYDwSK/EtV090K+iMJ7zx2S3HLVDIWFQdqMIsZWbnaGiba18aWhaA==} engines: {node: '>=14'} @@ -5450,6 +5503,10 @@ packages: lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + lru-cache@6.0.0: + resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} + engines: {node: '>=10'} + luxon@3.6.1: resolution: {integrity: sha512-tJLxrKJhO2ukZ5z0gyjY1zPh3Rh88Ej9P7jNrZiHMUXHae1yvI2imgOZtL1TO8TW6biMMKfTtAOoEJANgtWBMQ==} engines: {node: '>=12'} @@ -6204,6 +6261,10 @@ packages: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} + pony-cause@2.1.11: + resolution: {integrity: sha512-M7LhCsdNbNgiLYiP4WjsfLUuFmCfnjdF6jKe2R9NKl4WFN+HZPGHJZ9lnLP7f9ZnKe3U9nuWD0szirmj+migUg==} + engines: {node: '>=12.0.0'} + possible-typed-array-names@1.1.0: resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} engines: {node: '>= 0.4'} @@ -6601,6 +6662,11 @@ packages: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true + semver@7.5.4: + resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} + engines: {node: '>=10'} + hasBin: true + semver@7.7.2: resolution: {integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==} engines: {node: '>=10'} @@ -7166,6 +7232,10 @@ packages: resolution: {integrity: sha512-ZPtzy0hu4cZjv3z5NW9gfKnNLjoz4y6uv4HlelAjDK7sY/xOkKZv9xK/WQpcsBB3jEybChz9DPC2U/+cusjJVQ==} engines: {node: '>=18'} + umzug@3.8.2: + resolution: {integrity: sha512-BEWEF8OJjTYVC56GjELeHl/1XjFejrD7aHzn+HldRJTx+pL1siBrKHZC8n4K/xL3bEzVA9o++qD1tK2CpZu4KA==} + engines: {node: '>=12'} + unbox-primitive@1.1.0: resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} engines: {node: '>= 0.4'} @@ -9081,6 +9151,25 @@ snapshots: - supports-color - tedious + '@mikro-orm/migrations@6.4.16(@mikro-orm/core@6.4.16)(@types/node@22.15.30)(pg@8.16.0)': + dependencies: + '@mikro-orm/core': 6.4.16 + '@mikro-orm/knex': 6.4.16(@mikro-orm/core@6.4.16)(pg@8.16.0) + fs-extra: 11.3.0 + umzug: 3.8.2(@types/node@22.15.30) + transitivePeerDependencies: + - '@types/node' + - better-sqlite3 + - libsql + - mariadb + - mysql + - mysql2 + - pg + - pg-native + - sqlite3 + - supports-color + - tedious + '@mikro-orm/nestjs@6.1.1(@mikro-orm/core@6.4.16)(@nestjs/common@11.1.3(class-transformer@0.5.1)(class-validator@0.14.2)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.3)': dependencies: '@mikro-orm/core': 6.4.16 @@ -9516,6 +9605,35 @@ snapshots: '@rtsao/scc@1.1.0': {} + '@rushstack/node-core-library@5.13.0(@types/node@22.15.30)': + dependencies: + ajv: 8.13.0 + ajv-draft-04: 1.0.0(ajv@8.13.0) + ajv-formats: 3.0.1(ajv@8.13.0) + fs-extra: 11.3.3 + import-lazy: 4.0.0 + jju: 1.4.0 + resolve: 1.22.10 + semver: 7.5.4 + optionalDependencies: + '@types/node': 22.15.30 + + '@rushstack/terminal@0.15.2(@types/node@22.15.30)': + dependencies: + '@rushstack/node-core-library': 5.13.0(@types/node@22.15.30) + supports-color: 8.1.1 + optionalDependencies: + '@types/node': 22.15.30 + + '@rushstack/ts-command-line@4.23.7(@types/node@22.15.30)': + dependencies: + '@rushstack/terminal': 0.15.2(@types/node@22.15.30) + '@types/argparse': 1.0.38 + argparse: 1.0.10 + string-argv: 0.3.2 + transitivePeerDependencies: + - '@types/node' + '@scarf/scarf@1.4.0': {} '@sec-ant/readable-stream@0.4.1': {} @@ -9967,6 +10085,8 @@ snapshots: tslib: 2.8.1 optional: true + '@types/argparse@1.0.38': {} + '@types/babel__core@7.20.5': dependencies: '@babel/parser': 7.27.5 @@ -10520,10 +10640,18 @@ snapshots: dependencies: humanize-ms: 1.2.1 + ajv-draft-04@1.0.0(ajv@8.13.0): + optionalDependencies: + ajv: 8.13.0 + ajv-formats@2.1.1(ajv@8.17.1): optionalDependencies: ajv: 8.17.1 + ajv-formats@3.0.1(ajv@8.13.0): + optionalDependencies: + ajv: 8.13.0 + ajv-formats@3.0.1(ajv@8.17.1): optionalDependencies: ajv: 8.17.1 @@ -10544,6 +10672,13 @@ snapshots: json-schema-traverse: 0.4.1 uri-js: 4.4.1 + ajv@8.13.0: + dependencies: + fast-deep-equal: 3.1.3 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + uri-js: 4.4.1 + ajv@8.17.1: dependencies: fast-deep-equal: 3.1.3 @@ -12242,6 +12377,12 @@ snapshots: jsonfile: 6.1.0 universalify: 2.0.1 + fs-extra@11.3.3: + dependencies: + graceful-fs: 4.2.11 + jsonfile: 6.1.0 + universalify: 2.0.1 + fs-minipass@2.1.0: dependencies: minipass: 3.3.6 @@ -12672,6 +12813,8 @@ snapshots: parent-module: 1.0.1 resolve-from: 4.0.0 + import-lazy@4.0.0: {} + import-local@3.2.0: dependencies: pkg-dir: 4.2.0 @@ -13285,6 +13428,8 @@ snapshots: jiti@2.4.2: {} + jju@1.4.0: {} + js-beautify@1.15.4: dependencies: config-chain: 1.1.13 @@ -13664,6 +13809,10 @@ snapshots: dependencies: yallist: 3.1.1 + lru-cache@6.0.0: + dependencies: + yallist: 4.0.0 + luxon@3.6.1: {} magic-string@0.30.17: @@ -14620,6 +14769,8 @@ snapshots: pluralize@8.0.0: {} + pony-cause@2.1.11: {} + possible-typed-array-names@1.1.0: {} postgres-array@2.0.0: {} @@ -15074,6 +15225,10 @@ snapshots: semver@6.3.1: {} + semver@7.5.4: + dependencies: + lru-cache: 6.0.0 + semver@7.7.2: {} send@1.2.0: @@ -15714,6 +15869,16 @@ snapshots: uint8array-extras@1.4.0: {} + umzug@3.8.2(@types/node@22.15.30): + dependencies: + '@rushstack/ts-command-line': 4.23.7(@types/node@22.15.30) + emittery: 0.13.1 + fast-glob: 3.3.3 + pony-cause: 2.1.11 + type-fest: 4.41.0 + transitivePeerDependencies: + - '@types/node' + unbox-primitive@1.1.0: dependencies: call-bound: 1.0.4 diff --git a/src/modules/bills/bills.controller.ts b/src/modules/bills/bills.controller.ts index 43a2fcf..17bde7d 100644 --- a/src/modules/bills/bills.controller.ts +++ b/src/modules/bills/bills.controller.ts @@ -21,12 +21,14 @@ export class BillsController { @ApiOperation({ summary: "Create water bill" }) @Post("water") + @ApiHeader({ name: "x-business-id" }) createWaterBill(@Body() dto: CreateWaterBillDto, @BusinessDec() business: Business) { return this.billsService.createWaterBill(dto, business); } @ApiOperation({ summary: "Create water bill from excel file" }) @ApiConsumes("multipart/form-data") + @ApiHeader({ name: "x-business-id" }) @UseInterceptors(FileInterceptor("file")) @ApiBody({ type: CreateWaterBillFromExcelDto }) @Post("water/excel") @@ -39,6 +41,7 @@ export class BillsController { } @ApiOperation({ summary: "Create charge bill" }) + @ApiHeader({ name: "x-business-id" }) @Post("charge") createChargeBill(@Body() dto: CreateChargeBillDto, @BusinessDec() business: Business) { return this.billsService.createChargeBill(dto, business); diff --git a/src/modules/bills/bills.module.ts b/src/modules/bills/bills.module.ts index 536cd72..151e992 100644 --- a/src/modules/bills/bills.module.ts +++ b/src/modules/bills/bills.module.ts @@ -8,10 +8,15 @@ import { BusinessesModule } from "../businesses/businesses.module"; import { CompaniesModule } from "../companies/companies.module"; import { NotificationModule } from "../notifications/notifications.module"; import { InvoicesModule } from "../invoices/invoices.module"; +import { BullModule } from "@nestjs/bullmq"; +import { INVOICE } from "../invoices/constants"; @Module({ - imports: [MikroOrmModule.forFeature([Bill]), CompaniesModule, BusinessesModule,NotificationModule,InvoicesModule], + imports: [ + BullModule.registerQueue({ name: INVOICE.QUEUE_NAME }), + MikroOrmModule.forFeature([Bill]), CompaniesModule, BusinessesModule + , NotificationModule, InvoicesModule], controllers: [BillsController], providers: [BillsService], }) -export class BillsModule {} +export class BillsModule { } diff --git a/src/modules/bills/bills.service.ts b/src/modules/bills/bills.service.ts index af2a272..98692aa 100644 --- a/src/modules/bills/bills.service.ts +++ b/src/modules/bills/bills.service.ts @@ -19,7 +19,10 @@ import { CompaniesService } from "../companies/services/companies.service"; import { InvoiceItem } from "../invoices/entities/invoice-item.entity"; import { Invoice } from "../invoices/entities/invoice.entity"; import { NotificationQueue } from "../notifications/queue/notification.queue"; -import { InvoicesService } from "../invoices/providers/invoices.service"; +import { InjectQueue } from "@nestjs/bullmq"; +import { INVOICE } from "../invoices/constants"; +import { Queue } from "bullmq"; + @Injectable() export class BillsService { @@ -27,8 +30,9 @@ export class BillsService { private readonly em: EntityManager, private readonly companiesService: CompaniesService, private readonly billRepository: BillsRepository, + @InjectQueue(INVOICE.QUEUE_NAME) + private readonly invoiceQueue: Queue, private readonly notificationQueue: NotificationQueue, - private readonly invoicesService: InvoicesService, ) { } @@ -76,35 +80,14 @@ export class BillsService { }); invoice.items.add(invoiceItem); - - await this.notificationQueue.addInvoiceCreationNotification(company.user.id, { - invoiceId: invoice.numericId.toString(), - dueDate: invoice.dueDate, - createDate: invoice.createdAt, - price: new Decimal(invoice.totalPrice).toNumber(), - userPhone: company.user.phone, - userEmail: company.user.email, - items: invoiceItem.name, - paidAt: invoice.paidAt, - }); - - await this.invoicesService.scheduleInvoiceJobs(invoice, { - companyId: company.id, - items: [ - { - name: invoiceItem.name, - count: invoiceItem.count, - unitPrice: new Decimal(invoiceItem.unitPrice).toNumber(), - discount: new Decimal(invoiceItem.discount).toNumber(), - }, - ], - }); em.persist(invoice); } await em.flush(); await em.commit(); + await this.addInvoiceReminderJobs(bill.id); + return bill; } catch (error) { await em.rollback(); @@ -112,6 +95,34 @@ export class BillsService { } } + private async addInvoiceReminderJobs(billId: string) { + const invoices = await this.em.find(Invoice, { bill: { id: billId } }, { populate: ["items", "company","company.user"] }); + + for (const invoice of invoices) { + await this.notificationQueue.addInvoiceCreationNotification(invoice.company.user.id, { + invoiceId: invoice.numericId.toString(), + dueDate: invoice.dueDate, + createDate: invoice.createdAt, + price: new Decimal(invoice.totalPrice).toNumber(), + userPhone: invoice.company.user.phone, + userEmail: invoice.company.user.email, + items: invoice.items[0].name, + paidAt: invoice.paidAt, + }); + + await this.invoiceQueue.add( + INVOICE.REMINDER_JOB_NAME, + { invoiceId: invoice.id }, + { + delay: dayjs(invoice.dueDate).subtract(INVOICE.DAYS_BEFORE_OVERDUE, "day").diff(dayjs()), + attempts: INVOICE.REMINDER_JOB_ATTEMPTS, + backoff: { type: "exponential", delay: INVOICE.REMINDER_JOB_BACKOFF }, + priority: INVOICE.REMINDER_JOB_PRIORITY, + }, + ); + } + } + async createWaterBillByExcel(file: IFile, dto: CreateWaterBillFromExcelDto, business: Business) { const values = await this.parseWaterBillExcel(file.buffer); if (values.length === 0) { @@ -155,7 +166,7 @@ export class BillsService { const companies = await this.companiesService.findAllBybusinessId(business.id, em); for (const company of companies) { - const subtotal = new Decimal(chargeRate); + const subtotal = new Decimal(chargeRate).mul(company.metrage); const tax = subtotal.mul(0.1); const totalPrice = subtotal.add(tax); @@ -185,6 +196,8 @@ export class BillsService { await em.flush(); await em.commit(); + await this.addInvoiceReminderJobs(bill.id) + return bill; } catch (error) { await em.rollback(); diff --git a/src/modules/companies/DTO/create-company.dto.ts b/src/modules/companies/DTO/create-company.dto.ts index 9da6dc4..1aa3fba 100644 --- a/src/modules/companies/DTO/create-company.dto.ts +++ b/src/modules/companies/DTO/create-company.dto.ts @@ -76,11 +76,10 @@ export class CreateCompanyDto extends PickType(CompleteRegistrationDto, ["phone" @ApiProperty({ description: "آدرس تصویر کاور", example: "https://www.example.com/cover.jpg" }) coverImageUrl: string; - @IsOptional() @IsInt({ message: CompanyMessage.METRAGE_MUST_BE_INT }) @Min(1, { message: CompanyMessage.METRAGE_MUST_BE_POSITIVE }) @ApiProperty({ description: "متراژ شرکت (متر مربع)", example: 500 }) - metrage?: number; + metrage: number; @IsOptional() @IsNotEmpty({ message: CompanyMessage.IS_ACTIVE_REQUIRED }) @@ -126,6 +125,7 @@ export class CreateCompanyRequestDto extends PickType(CreateCompanyDto, [ "industryId", "products", "services", + "metrage" ]) { @IsNotEmpty({ message: CompanyMessage.CHIEF_EXECUTIVE_REQUIRED }) @IsString({ message: CompanyMessage.CHIEF_EXECUTIVE_MUST_BE_STRING }) diff --git a/src/modules/companies/entities/company.entity.ts b/src/modules/companies/entities/company.entity.ts index accb69c..d0868fb 100644 --- a/src/modules/companies/entities/company.entity.ts +++ b/src/modules/companies/entities/company.entity.ts @@ -48,8 +48,8 @@ export class Company extends BaseEntity { @Property({ type: "varchar", length: 255 }) coverImageUrl!: string; - @Property({ type: "int", nullable: true }) - metrage?: number; + @Property({ type: "int", nullable: false }) + metrage!: number; @Property({ type: "boolean", default: true }) isActive!: boolean & Opt;