Skip to Content
File StructurePackagesDbDocumentation for service.ts

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.

ColumnData TypeDescription
idserialUnique identifier for the log entry. Primary key.
serviceOrderIdvarcharIdentifier of the service order. References serviceOrder.id.
userIdvarcharIdentifier of the user. References user.id.
actionIdintegerIdentifier of the action. References serviceOrderLogActionLU.id.
organizationIdvarcharIdentifier of the organization. References organization.id.
fieldvarcharField affected by the action.
oldValuevarcharOld value of the field.
newValuevarcharNew value of the field.
createdAttimestampTimestamp when the log entry was created. Default is the current time.
updatedAttimestampTimestamp when the log entry was last updated. Updates automatically.
isActivebooleanIndicates if the log entry is active. Default is true.
createdByIdtextIdentifier of the user who created the log entry. References user.id.
updatedByIdtextIdentifier of the user who last updated the log entry. References user.id.

serviceOrderStatusLU

The serviceOrderStatusLU table stores the possible statuses of a service order.

ColumnData TypeDescription
idserialUnique identifier for the status. Primary key.
namevarcharName of the status.
descriptionvarcharDescription of the status.
createdAttimestampTimestamp when the status was created. Default is the current time.
updatedAttimestampTimestamp when the status was last updated. Updates automatically.
isActivebooleanIndicates if the status is active. Default is true.
createdByIdtextIdentifier of the user who created the status. References user.id.
updatedByIdtextIdentifier of the user who last updated the status. References user.id.

serviceOrderStatus

The serviceOrderStatus table stores the current status of a service order.

ColumnData TypeDescription
idserialUnique identifier for the status. Primary key.
serviceOrderIdvarcharIdentifier of the service order. References serviceOrder.id.
statusIdintegerIdentifier of the status. References serviceOrderStatusLU.id.
createdAttimestampTimestamp when the status was created. Default is the current time.
updatedAttimestampTimestamp when the status was last updated. Updates automatically.
isActivebooleanIndicates if the status is active. Default is true.
createdByIdtextIdentifier of the user who created the status. References user.id.
updatedByIdtextIdentifier of the user who last updated the status. References user.id.

serviceOrder

The serviceOrder table stores service orders.

ColumnData TypeDescription
idvarcharUnique identifier for the service order. Primary key.
serviceOrderNumberserialNumber of the service order.
organizationIdvarcharIdentifier of the organization. References organization.id.
originAddressIdvarcharIdentifier of the origin address. References address.id.
destinationAddressIdvarcharIdentifier of the destination address. References address.id.
hiddenbooleanIndicates if the order is hidden. Default is false.
serviceOrderCategoryIdintegerIdentifier of the service order category. References serviceOrderCategoryLU.id.
fareTypeIdintegerIdentifier of the fare type.
assistIdintegerIdentifier of the assist. References assist.id.
damageTypeIdintegerIdentifier of the damage type. References damageTypeLU.id.
serviceOrderTypeIdintegerIdentifier of the service order type. References serviceOrderTypeLU.id.
promisedTimevarcharPromised time for the order.
commentsvarcharComments about the order.
isBookedbooleanIndicates if the order is booked. Default is false.
assistReferencevarcharReference for the assist.
createdAttimestampTimestamp when the order was created. Default is the current time.
updatedAttimestampTimestamp when the order was last updated. Updates automatically.
isActivebooleanIndicates if the order is active. Default is true.
createdByIdtextIdentifier of the user who created the order. References user.id.
updatedByIdtextIdentifier 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 the serviceOrder table.

serviceOrderRelations

Defines the relationships for the serviceOrder table.

  • historicStatus: One-to-many relationship with the serviceOrderStatus table.
  • originAddress: One-to-one relationship with the address table.
  • destinationAddress: One-to-one relationship with the address table.
  • organization: One-to-one relationship with the organization table.
  • serviceOrderCategory: One-to-one relationship with the serviceOrderCategoryLU table.
  • fareType: One-to-one relationship with the serviceOrderCategoryLU table.
  • assist: One-to-one relationship with the assist table.
  • damageType: One-to-one relationship with the damageTypeLU table.
  • serviceOrderType: One-to-one relationship with the serviceOrderTypeLU table.
  • car: One-to-one relationship with the car table.
  • contactInformation: One-to-many relationship with the contactInformation table.

serviceOrderStatusRelations

Defines the relationships for the serviceOrderStatus table.

  • serviceOrder: One-to-one relationship with the serviceOrder table.
  • status: One-to-one relationship with the serviceOrderStatusLU table.
  • contact: One-to-one relationship with the contactInformation table.
  • assist: One-to-one relationship with the assist table.
  • car: One-to-one relationship with the car table.
  • originAddress: One-to-one relationship with the address table.
  • destinationAddress: One-to-one relationship with the address table.
  • organization: One-to-one relationship with the organization table.
  • serviceOrderCategory: One-to-one relationship with the serviceOrderCategoryLU table.
  • fareType: One-to-one relationship with the serviceOrderCategoryLU table.
  • damageType: One-to-one relationship with the damageTypeLU table.
  • serviceOrderType: One-to-one relationship with the serviceOrderTypeLU table.

Class Diagram

Last updated on