diff --git a/database/migrations/.snapshot-negareh.json b/database/migrations/.snapshot-negareh.json deleted file mode 100644 index 1dd0ea0..0000000 --- a/database/migrations/.snapshot-negareh.json +++ /dev/null @@ -1,2487 +0,0 @@ -{ - "namespaces": [ - "public" - ], - "name": "public", - "tables": [ - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "parent_id": { - "name": "parent_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "avatar_url": { - "name": "avatar_url", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - } - }, - "name": "categories", - "schema": "public", - "indexes": [ - { - "keyName": "categories_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "categories_parent_id_foreign": { - "constraintName": "categories_parent_id_foreign", - "columnNames": [ - "parent_id" - ], - "localTableName": "public.categories", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.categories", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "product", - "print" - ], - "mappedType": "enum" - }, - "entity_id": { - "name": "entity_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "name": { - "name": "name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "text", - "textarea", - "number", - "select", - "radio", - "checkbox", - "date" - ], - "mappedType": "enum" - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - }, - "multiple": { - "name": "multiple", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - } - }, - "name": "field", - "schema": "public", - "indexes": [ - { - "keyName": "field_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "value": { - "name": "value", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "field_id": { - "name": "field_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - } - }, - "name": "field_option", - "schema": "public", - "indexes": [ - { - "keyName": "field_option_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "field_option_field_id_foreign": { - "constraintName": "field_option_field_id_foreign", - "columnNames": [ - "field_id" - ], - "localTableName": "public.field_option", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.field", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "code": { - "name": "code", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "otp", - "schema": "public", - "indexes": [ - { - "keyName": "otp_phone_index", - "columnNames": [ - "phone" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "otp_pkey", - "columnNames": [ - "phone" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "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": [ - "manage_products", - "manage_categories", - "view_all_request_order", - "view_all_invoiced_orders", - "view_my_assigned_invoiced_requests", - "view_all_orders", - "create_order", - "update_order", - "assign_designer", - "create_order_print", - "change_order_status", - "remove_order", - "manage_admins", - "manage_roles", - "manage_users", - "manage_payments", - "manage_settings", - "manage_form_builder", - "manage_print" - ], - "mappedType": "enum" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - } - }, - "name": "permissions", - "schema": "public", - "indexes": [ - { - "keyName": "permissions_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "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" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - } - }, - "name": "print", - "schema": "public", - "indexes": [ - { - "keyName": "print_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "category_id": { - "name": "category_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "desc": { - "name": "desc", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "quantities": { - "name": "quantities", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "link_url": { - "name": "link_url", - "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" - }, - "images": { - "name": "images", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "order": { - "name": "order", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - } - }, - "name": "products", - "schema": "public", - "indexes": [ - { - "keyName": "products_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "products_category_id_foreign": { - "constraintName": "products_category_id_foreign", - "columnNames": [ - "category_id" - ], - "localTableName": "public.products", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.categories", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "hashed_token": { - "name": "hashed_token", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "owner_id": { - "name": "owner_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "user", - "admin" - ], - "mappedType": "enum" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "refreshtokens", - "schema": "public", - "indexes": [ - { - "keyName": "refreshtokens_hashed_token_index", - "columnNames": [ - "hashed_token" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "refreshtokens_pkey", - "columnNames": [ - "hashed_token" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "name": { - "name": "name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "title": { - "name": "title", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - } - }, - "name": "roles", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "name" - ], - "composite": false, - "keyName": "roles_name_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "roles_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "first_name": { - "name": "first_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "last_name": { - "name": "last_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "role_id": { - "name": "role_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - } - }, - "name": "admins", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "phone" - ], - "composite": false, - "keyName": "admins_phone_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "admins_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "admins_role_id_foreign": { - "constraintName": "admins_role_id_foreign", - "columnNames": [ - "role_id" - ], - "localTableName": "public.admins", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.roles", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "admin_id": { - "name": "admin_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "events": { - "name": "events", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - } - }, - "name": "notification_preferences", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "admin_id" - ], - "composite": false, - "keyName": "notification_preferences_admin_id_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "notification_preferences_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "notification_preferences_admin_id_foreign": { - "constraintName": "notification_preferences_admin_id_foreign", - "columnNames": [ - "admin_id" - ], - "localTableName": "public.notification_preferences", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "cascade", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "role_id": { - "name": "role_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "permission_id": { - "name": "permission_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - } - }, - "name": "role_permissions", - "schema": "public", - "indexes": [ - { - "keyName": "role_permissions_pkey", - "columnNames": [ - "role_id", - "permission_id" - ], - "composite": true, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "role_permissions_role_id_foreign": { - "constraintName": "role_permissions_role_id_foreign", - "columnNames": [ - "role_id" - ], - "localTableName": "public.role_permissions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.roles", - "updateRule": "cascade" - }, - "role_permissions_permission_id_foreign": { - "constraintName": "role_permissions_permission_id_foreign", - "columnNames": [ - "permission_id" - ], - "localTableName": "public.role_permissions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.permissions", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "serial", - "unsigned": false, - "autoincrement": true, - "primary": true, - "nullable": false, - "mappedType": "integer" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "sms_logs", - "schema": "public", - "indexes": [ - { - "keyName": "sms_logs_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "first_name": { - "name": "first_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "last_name": { - "name": "last_name", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "phone": { - "name": "phone", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - }, - "gender": { - "name": "gender", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "default": "true", - "mappedType": "boolean" - }, - "max_credit": { - "name": "max_credit", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - }, - "addresse": { - "name": "addresse", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - } - }, - "name": "users", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "phone" - ], - "composite": false, - "keyName": "users_phone_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "users_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "user_id": { - "name": "user_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "creator_id": { - "name": "creator_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "order_number": { - "name": "order_number", - "type": "serial", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "discount": { - "name": "discount", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "sub_total": { - "name": "sub_total", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "tax_amount": { - "name": "tax_amount", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "total": { - "name": "total", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "paid_amount": { - "name": "paid_amount", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - }, - "balance": { - "name": "balance", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "integer" - }, - "estimated_days": { - "name": "estimated_days", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'request'", - "enumItems": [ - "request", - "invoiced", - "order" - ], - "mappedType": "enum" - }, - "payment_method": { - "name": "payment_method", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "invoiced_at": { - "name": "invoiced_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "enable_tax": { - "name": "enable_tax", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - } - }, - "name": "orders", - "schema": "public", - "indexes": [ - { - "keyName": "orders_user_id_index", - "columnNames": [ - "user_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "orders_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "orders_user_id_foreign": { - "constraintName": "orders_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.orders", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - }, - "orders_creator_id_foreign": { - "constraintName": "orders_creator_id_foreign", - "columnNames": [ - "creator_id" - ], - "localTableName": "public.orders", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "order_id": { - "name": "order_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "creator_id": { - "name": "creator_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "amount": { - "name": "amount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "token": { - "name": "token", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "method": { - "name": "method", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "Online", - "Cash", - "Credit" - ], - "mappedType": "enum" - }, - "gateway": { - "name": "gateway", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "enumItems": [ - "zarinpal" - ], - "mappedType": "enum" - }, - "transaction_id": { - "name": "transaction_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "pending", - "paid", - "failed", - "refunded" - ], - "mappedType": "enum" - }, - "verify_response": { - "name": "verify_response", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "paid_at": { - "name": "paid_at", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "failed_at": { - "name": "failed_at", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - }, - "attachments": { - "name": "attachments", - "type": "text[]", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "array" - }, - "description": { - "name": "description", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 255, - "mappedType": "string" - } - }, - "name": "payments", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "order_id" - ], - "composite": false, - "keyName": "payments_order_id_index", - "constraint": false, - "primary": false, - "unique": false - }, - { - "columnNames": [ - "token" - ], - "composite": false, - "keyName": "payments_token_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "payments_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "payments_order_id_foreign": { - "constraintName": "payments_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.payments", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.orders", - "updateRule": "cascade" - }, - "payments_creator_id_foreign": { - "constraintName": "payments_creator_id_foreign", - "columnNames": [ - "creator_id" - ], - "localTableName": "public.payments", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "order_id": { - "name": "order_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "product_id": { - "name": "product_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "created", - "invoiced", - "waiting_to_confirm_invoice", - "design_initiated", - "design_finished", - "design_revision", - "ready_to_printing", - "in_printing", - "ready_for_delivery", - "delivered", - "after_print_cover", - "after_print_boxing", - "after_print_cartoning", - "finished", - "canceled" - ], - "mappedType": "enum" - }, - "designer_id": { - "name": "designer_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "attributes": { - "name": "attributes", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "quantity": { - "name": "quantity", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "unit_price": { - "name": "unit_price", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "discount": { - "name": "discount", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "description": { - "name": "description", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "admin_description": { - "name": "admin_description", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "attachments": { - "name": "attachments", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "print_attributes": { - "name": "print_attributes", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "print_form_created_at": { - "name": "print_form_created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "order_items", - "schema": "public", - "indexes": [ - { - "keyName": "order_items_order_id_index", - "columnNames": [ - "order_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "order_items_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_items_order_id_foreign": { - "constraintName": "order_items_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_items", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.orders", - "updateRule": "cascade" - }, - "order_items_product_id_foreign": { - "constraintName": "order_items_product_id_foreign", - "columnNames": [ - "product_id" - ], - "localTableName": "public.order_items", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.products", - "updateRule": "cascade" - }, - "order_items_designer_id_foreign": { - "constraintName": "order_items_designer_id_foreign", - "columnNames": [ - "designer_id" - ], - "localTableName": "public.order_items", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "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" - }, - "user_id": { - "name": "user_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "admin_id": { - "name": "admin_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "attachments": { - "name": "attachments", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "order_item_id": { - "name": "order_item_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "parent_id": { - "name": "parent_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "read_at": { - "name": "read_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "ticket", - "schema": "public", - "indexes": [ - { - "keyName": "ticket_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "ticket_user_id_foreign": { - "constraintName": "ticket_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.ticket", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "ticket_admin_id_foreign": { - "constraintName": "ticket_admin_id_foreign", - "columnNames": [ - "admin_id" - ], - "localTableName": "public.ticket", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "ticket_order_item_id_foreign": { - "constraintName": "ticket_order_item_id_foreign", - "columnNames": [ - "order_item_id" - ], - "localTableName": "public.ticket", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_items", - "updateRule": "cascade" - }, - "ticket_parent_id_foreign": { - "constraintName": "ticket_parent_id_foreign", - "columnNames": [ - "parent_id" - ], - "localTableName": "public.ticket", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.ticket", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "user_id": { - "name": "user_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "admin_id": { - "name": "admin_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 26, - "mappedType": "character" - }, - "title": { - "name": "title", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "newRequest", - "invoiced", - "newOrder", - "designerAssign", - "paymentSuccess" - ], - "mappedType": "enum" - }, - "content": { - "name": "content", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "seen_at": { - "name": "seen_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "notifications", - "schema": "public", - "indexes": [ - { - "keyName": "notifications_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "notifications_user_id_foreign": { - "constraintName": "notifications_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.notifications", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "notifications_admin_id_foreign": { - "constraintName": "notifications_admin_id_foreign", - "columnNames": [ - "admin_id" - ], - "localTableName": "public.notifications", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.admins", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "user_id": { - "name": "user_id", - "type": "char(26)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 26, - "mappedType": "character" - }, - "order_id": { - "name": "order_id", - "type": "varchar(255)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 255, - "mappedType": "string" - }, - "amount": { - "name": "amount", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "balance": { - "name": "balance", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [], - "mappedType": "enum" - } - }, - "name": "credit_transactions", - "schema": "public", - "indexes": [ - { - "keyName": "credit_transactions_user_id_index", - "columnNames": [ - "user_id" - ], - "composite": false, - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "credit_transactions_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "credit_transactions_user_id_foreign": { - "constraintName": "credit_transactions_user_id_foreign", - "columnNames": [ - "user_id" - ], - "localTableName": "public.credit_transactions", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.users", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - } - ], - "nativeEnums": {} -} diff --git a/database/migrations/Migration20260218113230_init.ts b/database/migrations/Migration20260218113230_init.ts deleted file mode 100644 index 5d5d65b..0000000 --- a/database/migrations/Migration20260218113230_init.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { Migration } from '@mikro-orm/migrations'; - -export class Migration20260218113230_init extends Migration { - - override async up(): Promise { - this.addSql(`create table "categories" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "parent_id" char(26) null, "title" varchar(255) not null, "is_active" boolean not null default true, "avatar_url" varchar(255) null, "order" int null, constraint "categories_pkey" primary key ("id"));`); - - this.addSql(`create table "field" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "entity_type" text check ("entity_type" in ('product', 'print')) not null, "entity_id" char(26) not null, "name" varchar(255) not null, "type" text check ("type" in ('text', 'textarea', 'number', 'select', 'radio', 'checkbox', 'date')) not null, "is_required" boolean not null default false, "multiple" boolean not null default false, "order" int null, constraint "field_pkey" primary key ("id"));`); - - this.addSql(`create table "field_option" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "value" varchar(255) not null, "field_id" char(26) not null, "order" int null, constraint "field_option_pkey" primary key ("id"));`); - - this.addSql(`create table "otp" ("phone" varchar(255) not null, "code" varchar(255) not null, "expires_at" timestamptz not null, constraint "otp_pkey" primary key ("phone"));`); - this.addSql(`create index "otp_phone_index" on "otp" ("phone");`); - - this.addSql(`create table "permissions" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "name" text check ("name" in ('manage_products', 'manage_categories', 'view_all_request_order', 'view_all_invoiced_orders', 'view_my_assigned_invoiced_requests', 'view_all_orders', 'create_order', 'update_order', 'assign_designer', 'create_order_print', 'change_order_status', 'remove_order', 'manage_admins', 'manage_roles', 'manage_users', 'manage_payments', 'manage_settings', 'manage_form_builder', 'manage_print')) not null, "title" varchar(255) not null, constraint "permissions_pkey" primary key ("id"));`); - - this.addSql(`create table "print" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "title" varchar(255) not null, "order" int null, constraint "print_pkey" primary key ("id"));`); - - this.addSql(`create table "products" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "category_id" char(26) not null, "title" varchar(255) not null, "desc" varchar(255) not null, "quantities" jsonb not null, "link_url" text null, "is_active" boolean not null default true, "images" jsonb null, "order" int not null, constraint "products_pkey" primary key ("id"));`); - - this.addSql(`create table "refreshtokens" ("hashed_token" varchar(255) not null, "owner_id" varchar(255) not null, "type" text check ("type" in ('user', 'admin')) not null, "expires_at" timestamptz not null, constraint "refreshtokens_pkey" primary key ("hashed_token"));`); - this.addSql(`create index "refreshtokens_hashed_token_index" on "refreshtokens" ("hashed_token");`); - - this.addSql(`create table "roles" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "name" varchar(255) not null, "title" varchar(255) not null, "is_system" boolean not null default false, constraint "roles_pkey" primary key ("id"));`); - this.addSql(`alter table "roles" add constraint "roles_name_unique" unique ("name");`); - - this.addSql(`create table "admins" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "first_name" varchar(255) null, "last_name" varchar(255) null, "phone" varchar(255) not null, "role_id" char(26) not null, constraint "admins_pkey" primary key ("id"));`); - this.addSql(`alter table "admins" add constraint "admins_phone_unique" unique ("phone");`); - - this.addSql(`create table "notification_preferences" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "admin_id" char(26) null, "events" jsonb null, constraint "notification_preferences_pkey" primary key ("id"));`); - this.addSql(`alter table "notification_preferences" add constraint "notification_preferences_admin_id_unique" unique ("admin_id");`); - - this.addSql(`create table "role_permissions" ("role_id" char(26) not null, "permission_id" char(26) not null, constraint "role_permissions_pkey" primary key ("role_id", "permission_id"));`); - - this.addSql(`create table "sms_logs" ("id" serial primary key, "phone" varchar(255) not null, "created_at" timestamptz not null);`); - - this.addSql(`create table "users" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "first_name" varchar(255) null, "last_name" varchar(255) null, "phone" varchar(255) not null, "is_active" boolean not null default true, "gender" boolean null default true, "max_credit" int not null default 0, "addresse" varchar(255) null, constraint "users_pkey" primary key ("id"));`); - this.addSql(`alter table "users" add constraint "users_phone_unique" unique ("phone");`); - - this.addSql(`create table "orders" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "user_id" char(26) not null, "creator_id" char(26) null, "order_number" serial, "discount" int null, "sub_total" int null, "tax_amount" int null, "total" int null, "paid_amount" int not null default 0, "balance" int not null default 0, "estimated_days" int null, "status" text check ("status" in ('request', 'invoiced', 'order')) not null default 'request', "payment_method" varchar(255) null, "invoiced_at" timestamptz null, "enable_tax" boolean not null default false, constraint "orders_pkey" primary key ("id"));`); - this.addSql(`create index "orders_user_id_index" on "orders" ("user_id");`); - - this.addSql(`create table "payments" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "order_id" char(26) not null, "creator_id" char(26) null, "amount" numeric(10,0) not null, "token" varchar(255) null, "method" text check ("method" in ('Online', 'Cash', 'Credit')) not null, "gateway" text check ("gateway" in ('zarinpal')) null, "transaction_id" varchar(255) null, "status" text check ("status" in ('pending', 'paid', 'failed', 'refunded')) not null, "verify_response" jsonb null, "paid_at" varchar(255) null, "failed_at" varchar(255) null, "attachments" text[] null, "description" varchar(255) null, constraint "payments_pkey" primary key ("id"));`); - this.addSql(`create index "payments_order_id_index" on "payments" ("order_id");`); - this.addSql(`alter table "payments" add constraint "payments_token_unique" unique ("token");`); - - this.addSql(`create table "order_items" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "order_id" char(26) not null, "product_id" char(26) not null, "status" text check ("status" in ('created', 'invoiced', 'waiting_to_confirm_invoice', 'design_initiated', 'design_finished', 'design_revision', 'ready_to_printing', 'in_printing', 'ready_for_delivery', 'delivered', 'after_print_cover', 'after_print_boxing', 'after_print_cartoning', 'finished', 'canceled')) not null, "designer_id" char(26) null, "attributes" jsonb null, "quantity" int not null, "unit_price" int null, "discount" int null, "description" text null, "admin_description" text null, "attachments" jsonb null, "print_attributes" jsonb null, "confirmed_at" timestamptz null, "print_form_created_at" timestamptz null, constraint "order_items_pkey" primary key ("id"));`); - this.addSql(`create index "order_items_order_id_index" on "order_items" ("order_id");`); - - this.addSql(`create table "ticket" ("id" char(26) not null, "deleted_at" timestamptz null, "content" text not null, "user_id" char(26) null, "admin_id" char(26) null, "attachments" jsonb null, "order_item_id" char(26) not null, "parent_id" char(26) null, "created_at" timestamptz not null default now(), "read_at" timestamptz null, constraint "ticket_pkey" primary key ("id"));`); - - this.addSql(`create table "notifications" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "user_id" char(26) null, "admin_id" char(26) null, "title" text check ("title" in ('newRequest', 'invoiced', 'newOrder', 'designerAssign', 'paymentSuccess')) not null, "content" varchar(255) not null, "seen_at" timestamptz null, constraint "notifications_pkey" primary key ("id"));`); - - this.addSql(`create table "credit_transactions" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "user_id" char(26) not null, "order_id" varchar(255) not null, "amount" numeric(10,0) not null, "balance" numeric(10,0) not null, "type" text check ("type" in ('')) not null, constraint "credit_transactions_pkey" primary key ("id"));`); - this.addSql(`create index "credit_transactions_user_id_index" on "credit_transactions" ("user_id");`); - - this.addSql(`alter table "categories" add constraint "categories_parent_id_foreign" foreign key ("parent_id") references "categories" ("id") on update cascade on delete set null;`); - - this.addSql(`alter table "field_option" add constraint "field_option_field_id_foreign" foreign key ("field_id") references "field" ("id") on update cascade;`); - - this.addSql(`alter table "products" add constraint "products_category_id_foreign" foreign key ("category_id") references "categories" ("id") on update cascade;`); - - this.addSql(`alter table "admins" add constraint "admins_role_id_foreign" foreign key ("role_id") references "roles" ("id") on update cascade;`); - - this.addSql(`alter table "notification_preferences" add constraint "notification_preferences_admin_id_foreign" foreign key ("admin_id") references "admins" ("id") on update cascade on delete cascade;`); - - this.addSql(`alter table "role_permissions" add constraint "role_permissions_role_id_foreign" foreign key ("role_id") references "roles" ("id") on update cascade;`); - this.addSql(`alter table "role_permissions" add constraint "role_permissions_permission_id_foreign" foreign key ("permission_id") references "permissions" ("id") on update cascade;`); - - this.addSql(`alter table "orders" add constraint "orders_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade;`); - this.addSql(`alter table "orders" add constraint "orders_creator_id_foreign" foreign key ("creator_id") references "admins" ("id") on update cascade on delete set null;`); - - this.addSql(`alter table "payments" add constraint "payments_order_id_foreign" foreign key ("order_id") references "orders" ("id") on update cascade;`); - this.addSql(`alter table "payments" add constraint "payments_creator_id_foreign" foreign key ("creator_id") references "admins" ("id") on update cascade on delete set null;`); - - this.addSql(`alter table "order_items" add constraint "order_items_order_id_foreign" foreign key ("order_id") references "orders" ("id") on update cascade;`); - this.addSql(`alter table "order_items" add constraint "order_items_product_id_foreign" foreign key ("product_id") references "products" ("id") on update cascade;`); - this.addSql(`alter table "order_items" add constraint "order_items_designer_id_foreign" foreign key ("designer_id") references "admins" ("id") on update cascade on delete set null;`); - - this.addSql(`alter table "ticket" add constraint "ticket_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete set null;`); - this.addSql(`alter table "ticket" add constraint "ticket_admin_id_foreign" foreign key ("admin_id") references "admins" ("id") on update cascade on delete set null;`); - this.addSql(`alter table "ticket" add constraint "ticket_order_item_id_foreign" foreign key ("order_item_id") references "order_items" ("id") on update cascade;`); - this.addSql(`alter table "ticket" add constraint "ticket_parent_id_foreign" foreign key ("parent_id") references "ticket" ("id") on update cascade on delete set null;`); - - this.addSql(`alter table "notifications" add constraint "notifications_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete set null;`); - this.addSql(`alter table "notifications" add constraint "notifications_admin_id_foreign" foreign key ("admin_id") references "admins" ("id") on update cascade on delete set null;`); - - this.addSql(`alter table "credit_transactions" add constraint "credit_transactions_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade;`); - } - -} diff --git a/database/migrations/Migration20260218114512_orderCalc.ts b/database/migrations/Migration20260218114512_orderCalc.ts deleted file mode 100644 index a7abef7..0000000 --- a/database/migrations/Migration20260218114512_orderCalc.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Migration } from '@mikro-orm/migrations'; - -export class Migration20260218114512_orderCalc extends Migration { - - override async up(): Promise { - this.addSql(` - CREATE OR REPLACE FUNCTION update_order_paid_amount() - RETURNS TRIGGER AS $$ - BEGIN - UPDATE orders o - SET paid_amount = ( - SELECT COALESCE(SUM(p.amount), 0) - FROM payments p - WHERE p.order_id = COALESCE(NEW.order_id, OLD.order_id) - AND p.status = 'Paid' - ) - WHERE o.id = COALESCE(NEW.order_id, OLD.order_id); - - RETURN NULL; - END; - $$ LANGUAGE plpgsql; - `); - - this.addSql(` - CREATE TRIGGER trg_update_order_paid_amount - AFTER INSERT OR UPDATE OR DELETE - ON payments - FOR EACH ROW - EXECUTE FUNCTION update_order_paid_amount(); - `); - - this.addSql(` - CREATE INDEX idx_payments_order_status - ON payments(order_id, status); - `); - } - - override async down(): Promise { - this.addSql(`DROP TRIGGER IF EXISTS trg_update_order_paid_amount ON payments;`); - this.addSql(`DROP FUNCTION IF EXISTS update_order_paid_amount;`); - this.addSql(`DROP INDEX IF EXISTS idx_payments_order_status;`); - } - -} diff --git a/src/modules/invoice/invoice.module.ts b/src/modules/invoice/invoice.module.ts index 0ea6f6a..868ad1e 100644 --- a/src/modules/invoice/invoice.module.ts +++ b/src/modules/invoice/invoice.module.ts @@ -6,13 +6,20 @@ import { Invoice } from './entities/invoice.entity'; import { InvoiceItem } from './entities/invoice-item.entity'; import { ProductModule } from '../product/product.module'; import { InvoiceRepository } from './repositories/invoice.repository'; +import { JwtModule } from '@nestjs/jwt'; +import { RolesModule } from '../roles/roles.module'; +import { AuthModule } from '../auth/auth.module'; @Module({ imports: [ MikroOrmModule.forFeature([Invoice, InvoiceItem]), ProductModule, + RolesModule, + JwtModule, + AuthModule ], controllers: [InvoiceController], providers: [InvoiceService, InvoiceRepository], + exports: [InvoiceService, InvoiceRepository], }) -export class InvoiceModule {} +export class InvoiceModule { } diff --git a/src/modules/request/request.controller.ts b/src/modules/request/request.controller.ts index 2b407a0..67e2a7c 100644 --- a/src/modules/request/request.controller.ts +++ b/src/modules/request/request.controller.ts @@ -61,14 +61,14 @@ export class RequestController { return this.requestService.findOneAsAdmin(id); } - @Patch('public/request/:id') + @Patch('admin/request/:id') @UseGuards(AdminAuthGuard) @Permissions(PermissionEnum.UPDATE_REQUEST) updateRequestAsAdmin(@Param('id') id: string, @Body() dto: UpdateRequestDto) { return this.requestService.updateAsAdmin(id, dto); } - @Delete('public/request/:id') + @Delete('admin/request/:id') @UseGuards(AdminAuthGuard) @Permissions(PermissionEnum.DELETE_REQUEST) removeRequestAsAdmin(@Param('id') id: string) { diff --git a/src/modules/request/request.module.ts b/src/modules/request/request.module.ts index 8a37898..8ad8c4e 100644 --- a/src/modules/request/request.module.ts +++ b/src/modules/request/request.module.ts @@ -7,12 +7,16 @@ import { RequestItem } from './entities/request-item.entity'; import { RequestRepository } from './repositories/request.repository'; import { UserModule } from '../user/user.module'; import { ProductModule } from '../product/product.module'; +import { AuthModule } from '../auth/auth.module'; +import { JwtModule } from '@nestjs/jwt'; @Module({ imports: [ MikroOrmModule.forFeature([Request, RequestItem]), UserModule, ProductModule, + JwtModule, + AuthModule ], controllers: [RequestController], providers: [RequestService, RequestRepository],