Documentation for service.ts
This file defines several tables and their relationships using drizzle-orm for managing service orders and their logs in a PostgreSQL database.
Tables
serviceOrderLog
The serviceOrderLog table stores logs of actions performed on service orders.
| Column | Data Type | Description |
|---|---|---|
| id | serial | Unique identifier for the log entry. Primary key. |
| serviceOrderId | varchar | Identifier of the service order. References serviceOrder.id. |
| userId | varchar | Identifier of the user. References user.id. |
| actionId | integer | Identifier of the action. References serviceOrderLogActionLU.id. |
| organizationId | varchar | Identifier of the organization. References organization.id. |
| field | varchar | Field affected by the action. |
| oldValue | varchar | Old value of the field. |
| newValue | varchar | New value of the field. |
| createdAt | timestamp | Timestamp when the log entry was created. Default is the current time. |
| updatedAt | timestamp | Timestamp when the log entry was last updated. Updates automatically. |
| isActive | boolean | Indicates if the log entry is active. Default is true. |
| createdById | text | Identifier of the user who created the log entry. References user.id. |
| updatedById | text | Identifier of the user who last updated the log entry. References user.id. |
serviceOrderStatusLU
The serviceOrderStatusLU table stores the possible statuses of a service order.
| Column | Data Type | Description |
|---|---|---|
| id | serial | Unique identifier for the status. Primary key. |
| name | varchar | Name of the status. |
| description | varchar | Description of the status. |
| createdAt | timestamp | Timestamp when the status was created. Default is the current time. |
| updatedAt | timestamp | Timestamp when the status was last updated. Updates automatically. |
| isActive | boolean | Indicates if the status is active. Default is true. |
| createdById | text | Identifier of the user who created the status. References user.id. |
| updatedById | text | Identifier of the user who last updated the status. References user.id. |
serviceOrderStatus
The serviceOrderStatus table stores the current status of a service order.
| Column | Data Type | Description |
|---|---|---|
| id | serial | Unique identifier for the status. Primary key. |
| serviceOrderId | varchar | Identifier of the service order. References serviceOrder.id. |
| statusId | integer | Identifier of the status. References serviceOrderStatusLU.id. |
| createdAt | timestamp | Timestamp when the status was created. Default is the current time. |
| updatedAt | timestamp | Timestamp when the status was last updated. Updates automatically. |
| isActive | boolean | Indicates if the status is active. Default is true. |
| createdById | text | Identifier of the user who created the status. References user.id. |
| updatedById | text | Identifier of the user who last updated the status. References user.id. |
serviceOrder
The serviceOrder table stores service orders.
| Column | Data Type | Description |
|---|---|---|
| id | varchar | Unique identifier for the service order. Primary key. |
| serviceOrderNumber | serial | Number of the service order. |
| organizationId | varchar | Identifier of the organization. References organization.id. |
| originAddressId | varchar | Identifier of the origin address. References address.id. |
| destinationAddressId | varchar | Identifier of the destination address. References address.id. |
| hidden | boolean | Indicates if the order is hidden. Default is false. |
| serviceOrderCategoryId | integer | Identifier of the service order category. References serviceOrderCategoryLU.id. |
| fareTypeId | integer | Identifier of the fare type. |
| assistId | integer | Identifier of the assist. References assist.id. |
| damageTypeId | integer | Identifier of the damage type. References damageTypeLU.id. |
| serviceOrderTypeId | integer | Identifier of the service order type. References serviceOrderTypeLU.id. |
| promisedTime | varchar | Promised time for the order. |
| comments | varchar | Comments about the order. |
| isBooked | boolean | Indicates if the order is booked. Default is false. |
| assistReference | varchar | Reference for the assist. |
| createdAt | timestamp | Timestamp when the order was created. Default is the current time. |
| updatedAt | timestamp | Timestamp when the order was last updated. Updates automatically. |
| isActive | boolean | Indicates if the order is active. Default is true. |
| createdById | text | Identifier of the user who created the order. References user.id. |
| updatedById | text | Identifier of the user who last updated the order. References user.id. |
Relationships
serviceOrderLogRelations
Defines the relationships for the serviceOrderLog table.
serviceOrder: One-to-one relationship with theserviceOrdertable.
serviceOrderRelations
Defines the relationships for the serviceOrder table.
historicStatus: One-to-many relationship with theserviceOrderStatustable.originAddress: One-to-one relationship with theaddresstable.destinationAddress: One-to-one relationship with theaddresstable.organization: One-to-one relationship with theorganizationtable.serviceOrderCategory: One-to-one relationship with theserviceOrderCategoryLUtable.fareType: One-to-one relationship with theserviceOrderCategoryLUtable.assist: One-to-one relationship with theassisttable.damageType: One-to-one relationship with thedamageTypeLUtable.serviceOrderType: One-to-one relationship with theserviceOrderTypeLUtable.car: One-to-one relationship with thecartable.contactInformation: One-to-many relationship with thecontactInformationtable.
serviceOrderStatusRelations
Defines the relationships for the serviceOrderStatus table.
serviceOrder: One-to-one relationship with theserviceOrdertable.status: One-to-one relationship with theserviceOrderStatusLUtable.contact: One-to-one relationship with thecontactInformationtable.assist: One-to-one relationship with theassisttable.car: One-to-one relationship with thecartable.originAddress: One-to-one relationship with theaddresstable.destinationAddress: One-to-one relationship with theaddresstable.organization: One-to-one relationship with theorganizationtable.serviceOrderCategory: One-to-one relationship with theserviceOrderCategoryLUtable.fareType: One-to-one relationship with theserviceOrderCategoryLUtable.damageType: One-to-one relationship with thedamageTypeLUtable.serviceOrderType: One-to-one relationship with theserviceOrderTypeLUtable.
Class Diagram
Last updated on