@delpa/mt-prisma 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/generated/client/edge.js +425 -23
  2. package/dist/generated/client/index-browser.js +430 -29
  3. package/dist/generated/client/index.d.ts +71466 -28468
  4. package/dist/generated/client/index.js +426 -24
  5. package/dist/generated/client/package.json +3 -3
  6. package/dist/generated/client/query_compiler_fast_bg.js +2 -0
  7. package/dist/generated/client/query_compiler_fast_bg.wasm +0 -0
  8. package/dist/generated/client/query_compiler_fast_bg.wasm-base64.js +2 -0
  9. package/dist/generated/client/runtime/client.d.ts +4 -17
  10. package/dist/generated/client/runtime/client.js +20 -20
  11. package/dist/generated/client/runtime/wasm-compiler-edge.js +18 -18
  12. package/dist/generated/client/schema.prisma +648 -66
  13. package/dist/generated/client/wasm-edge-light-loader.mjs +1 -1
  14. package/dist/generated/client/wasm-worker-loader.mjs +1 -1
  15. package/dist/generated/generated/client/edge.js +225 -24
  16. package/dist/generated/generated/client/index-browser.js +218 -18
  17. package/dist/generated/generated/client/index.d.ts +63096 -34291
  18. package/dist/generated/generated/client/index.js +226 -25
  19. package/dist/generated/generated/client/package.json +3 -3
  20. package/dist/generated/generated/client/query_compiler_fast_bg.js +2 -0
  21. package/dist/generated/generated/client/query_compiler_fast_bg.wasm +0 -0
  22. package/dist/generated/generated/client/query_compiler_fast_bg.wasm-base64.js +2 -0
  23. package/dist/generated/generated/client/runtime/client.d.ts +4 -17
  24. package/dist/generated/generated/client/runtime/client.js +20 -20
  25. package/dist/generated/generated/client/runtime/wasm-compiler-edge.js +18 -18
  26. package/dist/generated/generated/client/schema.prisma +398 -73
  27. package/dist/generated/generated/client/wasm-edge-light-loader.mjs +1 -1
  28. package/dist/generated/generated/client/wasm-worker-loader.mjs +1 -1
  29. package/generated/client/edge.js +225 -24
  30. package/generated/client/index-browser.js +218 -18
  31. package/generated/client/index.d.ts +63096 -34291
  32. package/generated/client/index.js +226 -25
  33. package/generated/client/package.json +3 -3
  34. package/generated/client/query_compiler_fast_bg.js +2 -0
  35. package/generated/client/query_compiler_fast_bg.wasm +0 -0
  36. package/generated/client/query_compiler_fast_bg.wasm-base64.js +2 -0
  37. package/generated/client/runtime/client.d.ts +4 -17
  38. package/generated/client/runtime/client.js +20 -20
  39. package/generated/client/runtime/wasm-compiler-edge.js +18 -18
  40. package/generated/client/schema.prisma +398 -73
  41. package/generated/client/wasm-edge-light-loader.mjs +1 -1
  42. package/generated/client/wasm-worker-loader.mjs +1 -1
  43. package/package.json +1 -1
  44. package/prisma/migrations/20260127193502_enable_postgis/migration.sql +2 -0
  45. package/prisma/migrations/20260127193503_add_schema_tenders/migration.sql +410 -0
  46. package/prisma/migrations/20260202133514_agrega_product_in_handling_units/migration.sql +8 -0
  47. package/prisma/migrations/20260202150634_simplify_handling_unit_remove_redundant_fields/migration.sql +29 -0
  48. package/prisma/migrations/20260202162217_fix_reference_for_products/migration.sql +22 -0
  49. package/prisma/migrations/20260202163057_fix_vechicle_equipment_name/migration.sql +25 -0
  50. package/prisma/schema.prisma +495 -168
@@ -153,28 +153,68 @@ enum GpsProviders {
153
153
  ONIX
154
154
  SASCAR
155
155
  }
156
+
157
+ enum TenderStatus {
158
+ OPEN
159
+ CLOSED
160
+ AWARDED
161
+ CANCELLED
162
+ DRAFT
163
+ PAUSED
164
+ }
165
+
166
+ enum TenderType {
167
+ FIXED_PRICE_TENDER
168
+ TENDER_WITHOUT_FIXED_PRICES
169
+ }
170
+
171
+ enum TripType {
172
+ NATIONAL
173
+ INTERNATIONAL
174
+ }
175
+
176
+ enum ApplicationStatus {
177
+ PENDING
178
+ APPROVED
179
+ REJECTED
180
+ WITHDRAWN
181
+ }
182
+
183
+ enum LocationType {
184
+ CITY
185
+ STATE
186
+ COUNTRY
187
+ }
188
+
189
+ enum TenderMode {
190
+ PUBLIC
191
+ PRIVATE
192
+ }
193
+
156
194
  model Product {
157
- id String @id @default(uuid()) @db.Uuid
158
- client_id String @db.Uuid
159
- description String
160
- sku String @unique
161
- quantity Int @default(0)
162
- packaging_type PackagingType @default(BOX)
163
- category ProductCategory @default(OTHER)
164
- subcategory ProductSubcategory @default(OTHER)
165
- dimension_unit DimensionUnits @default(CM)
166
- length Float?
167
- width Float?
168
- height Float?
169
- weight_unit WeightUnits @default(KG)
170
- weight Float?
171
- is_active Boolean @default(true)
172
- created_at DateTime @default(now())
173
- updated_at DateTime @updatedAt
195
+ id String @id @default(uuid()) @db.Uuid
196
+ company_id String @db.Uuid
197
+ description String
198
+ sku String @unique
199
+ quantity Int @default(0)
200
+ packaging_type PackagingType @default(BOX)
201
+ category ProductCategory @default(OTHER)
202
+ subcategory ProductSubcategory @default(OTHER)
203
+ dimension_unit DimensionUnits @default(CM)
204
+ length Float?
205
+ width Float?
206
+ height Float?
207
+ weight_unit WeightUnits @default(KG)
208
+ weight Float?
209
+ is_active Boolean @default(true)
210
+ created_at DateTime @default(now())
211
+ updated_at DateTime @updatedAt
174
212
 
175
- client Client @relation(fields: [client_id], references: [id], onDelete: Cascade)
213
+ handlingUnits HandlingUnit[]
176
214
 
177
- @@index([client_id])
215
+ company Companies @relation(fields: [company_id], references: [id], onDelete: Cascade)
216
+
217
+ @@index([company_id])
178
218
  @@index([sku])
179
219
  @@index([category])
180
220
  @@map("products")
@@ -192,12 +232,11 @@ model Client {
192
232
  created_at DateTime @default(now())
193
233
  updated_at DateTime @updatedAt
194
234
 
195
- company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
235
+ company Companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
196
236
  addresses ClientAddress[]
197
237
  contacts ClientContact[]
198
238
  orders_as_shipper Order[] @relation("shipper_client")
199
239
  handling_units_as_consignee HandlingUnit[]
200
- products Product[]
201
240
 
202
241
  @@index([company_id])
203
242
  @@index([created_by])
@@ -256,85 +295,101 @@ model Order {
256
295
  shipper Client? @relation("shipper_client", fields: [shipper_id], references: [id], onDelete: SetNull)
257
296
  handling_units HandlingUnit[]
258
297
  routes Route[]
298
+ tenders Tender[]
259
299
 
260
300
  @@index([shipper_id])
261
301
  @@map("orders")
262
302
  }
263
303
 
264
- model companies {
304
+ model Companies {
265
305
  id String @id @default(uuid()) @db.Uuid
266
306
  tax_id String? @unique
267
307
  name String
268
308
  address Json? @default("{}")
269
309
  contact_info Json? @default("{}")
270
310
  country_code String?
311
+ is_validated Boolean? @default(false)
312
+ documents Json? @default("[]")
271
313
  created_at DateTime @default(now())
272
314
  updated_at DateTime @updatedAt
273
315
 
274
- clients Client[]
275
- vehicles Vehicle[]
276
- user_companies UserCompany[]
277
- equipments Equipment[]
278
- form_templates FormTemplate[]
279
- form_responses FormResponse[]
280
- forms Form[]
281
-
316
+ clients Client[]
317
+ vehicles Vehicle[]
318
+ user_companies UserCompany[]
319
+ equipments Equipment[]
320
+ form_templates FormTemplate[]
321
+ form_responses FormResponse[]
322
+ forms Form[]
323
+ tenders Tender[]
324
+ groups Group[]
325
+ companyLocations CompanyLocation[]
326
+ regularSuppliers RegularSupplier[]
327
+ products Product[]
328
+
329
+ regularSuppliers2 RegularSupplier[] @relation("SupplierCompany")
330
+
331
+ @@index([tax_id])
332
+ @@index([country_code])
333
+ @@index([name])
282
334
  @@map("companies")
283
335
  }
284
336
 
285
337
  model HandlingUnit {
286
- id String @id @default(uuid()) @db.Uuid
287
- order_id String @db.Uuid
288
- description String
289
- quantity Int @default(1)
290
- weight Float?
291
- weight_unit WeightUnits @default(KG)
292
- length Float?
293
- width Float?
294
- height Float?
295
- volume Float?
296
- dimension_unit DimensionUnits @default(CM)
297
- total_volume Float?
298
- total_weight Float?
299
- commodity String?
300
- delivery_contact Json? @default("{}")
301
- pickup_contact Json? @default("{}")
302
- delivery_address Json? @default("{}")
303
- pickup_address Json? @default("{}")
338
+ id String @id @default(uuid()) @db.Uuid
339
+ order_id String @db.Uuid
340
+ quantity Int @default(1)
341
+ delivery_contact Json? @default("{}")
342
+ pickup_contact Json? @default("{}")
343
+ delivery_address Json? @default("{}")
344
+ pickup_address Json? @default("{}")
304
345
  delivery_instructions String?
305
346
  pickup_instructions String?
306
- client_id String? @db.Uuid
307
- contact_notify Json? @default("[]")
347
+ client_id String? @db.Uuid
348
+ contact_notify Json? @default("[]")
308
349
  eta DateTime?
309
- created_at DateTime @default(now())
310
- updated_at DateTime @updatedAt
350
+ product_id String? @db.Uuid
351
+ notes String?
352
+ created_at DateTime @default(now())
353
+ updated_at DateTime @updatedAt
354
+
355
+ order Order @relation(fields: [order_id], references: [id], onDelete: Cascade)
356
+ client Client? @relation(fields: [client_id], references: [id], onDelete: SetNull)
357
+ product Product? @relation(fields: [product_id], references: [id], onDelete: SetNull)
311
358
 
312
- order Order @relation(fields: [order_id], references: [id], onDelete: Cascade)
313
- client Client? @relation(fields: [client_id], references: [id], onDelete: SetNull)
314
359
  route_handling_units RouteHandlingUnit[]
315
360
  address_handling_units AddressHandlingUnit[]
316
361
 
317
362
  @@index([order_id])
318
363
  @@index([client_id])
364
+ @@index([product_id])
319
365
  @@map("handling_units")
320
366
  }
321
367
 
322
368
  model User {
323
- id String @id @default(uuid()) @db.Uuid
324
- email String @unique
325
- name String
326
- password String
327
- role Roles @default(GUEST)
328
- created_at DateTime @default(now())
329
- updated_at DateTime @updatedAt
369
+ id String @id @default(uuid()) @db.Uuid
370
+ email String @unique
371
+ name String
372
+ password String
373
+ role Roles @default(GUEST)
374
+ driver_validated Boolean? @default(false)
375
+ documents Json? @default("[]")
376
+ created_at DateTime @default(now())
377
+ updated_at DateTime @updatedAt
330
378
 
331
- routes Route[]
332
- user_companies UserCompany[]
333
- sessions Session[]
334
- driverLocations DriverLocation[]
379
+ routes Route[]
380
+ user_companies UserCompany[]
381
+ sessions Session[]
382
+ driverLocations DriverLocation[]
335
383
  form_templates_created FormTemplate[]
336
- form_responses FormResponse[]
337
- forms_created Form[] @relation("FormCreator")
384
+ form_responses FormResponse[]
385
+ forms_created Form[] @relation("FormCreator")
386
+ tenders Tender[]
387
+ tenderChats TenderChat[] @relation("TenderChatSender")
388
+ tenderChats2 TenderChat[] @relation("TenderChatReceiver")
389
+ tenderApplications TenderApplication[] @relation("ApplicantUser")
390
+ tenderApplications2 TenderApplication[] @relation("UpdaterUser")
391
+ userGroups UserGroup[]
392
+ tenderNotifications TenderNotification[]
338
393
 
339
394
  @@map("users")
340
395
  }
@@ -348,7 +403,7 @@ model UserCompany {
348
403
  updated_at DateTime @updatedAt
349
404
 
350
405
  user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
351
- company companies @relation(fields: [company_id], references: [id], onDelete: Cascade)
406
+ company Companies @relation(fields: [company_id], references: [id], onDelete: Cascade)
352
407
 
353
408
  @@unique([user_id, company_id])
354
409
  @@index([user_id])
@@ -404,28 +459,33 @@ model VehicleModel {
404
459
  }
405
460
 
406
461
  model Vehicle {
407
- id String @id @default(uuid()) @db.Uuid
408
- license_plate String @unique
409
- brand_id String? @db.Uuid
410
- model_id String? @db.Uuid
411
- capacity Float?
412
- year Int?
413
- fuel_type FuelType? @default(DIESEL)
414
- color VehicleColor?
415
- chassis_number String? @unique
416
- size VehicleSize? @default(MEDIUM)
417
- gps_enabled Boolean @default(false)
418
- image_url Json? @default("[]")
419
- company_id String? @db.Uuid
420
- created_at DateTime @default(now())
421
- updated_at DateTime @updatedAt
422
-
423
- brand VehicleBrand? @relation(fields: [brand_id], references: [id], onDelete: SetNull)
424
- model VehicleModel? @relation(fields: [model_id], references: [id], onDelete: SetNull)
425
- company companies? @relation(fields: [company_id], references: [id], onDelete: Cascade)
426
- routes Route[]
427
- equipments Equipment[]
428
- vehicleLocations VehicleLocation[]
462
+ id String @id @default(uuid()) @db.Uuid
463
+ license_plate String @unique
464
+ brand_id String? @db.Uuid
465
+ model_id String? @db.Uuid
466
+ vehicle_type_id String? @db.Uuid
467
+ capacity Float?
468
+ year Int?
469
+ fuel_type FuelType? @default(DIESEL)
470
+ color VehicleColor?
471
+ chassis_number String? @unique
472
+ size VehicleSize? @default(MEDIUM)
473
+ gps_enabled Boolean @default(false)
474
+ image_url Json? @default("[]")
475
+ company_id String? @db.Uuid
476
+ is_validated Boolean? @default(false)
477
+ documents Json? @default("[]")
478
+ created_at DateTime @default(now())
479
+ updated_at DateTime @updatedAt
480
+
481
+ brand VehicleBrand? @relation(fields: [brand_id], references: [id], onDelete: SetNull)
482
+ model VehicleModel? @relation(fields: [model_id], references: [id], onDelete: SetNull)
483
+ company Companies? @relation(fields: [company_id], references: [id], onDelete: Cascade)
484
+ vehicle_type VehicleType? @relation(fields: [vehicle_type_id], references: [id], onDelete: SetNull)
485
+ routes Route[]
486
+ equipments Equipment[]
487
+ vehicleLocations VehicleLocation[]
488
+ tenderApplications TenderApplication[]
429
489
 
430
490
  @@index([company_id])
431
491
  @@index([brand_id])
@@ -574,12 +634,14 @@ model Equipment {
574
634
  status EquipmentStatus @default(ACTIVE)
575
635
  company_id String? @db.Uuid
576
636
  vehicle_id String? @db.Uuid
637
+ is_validated Boolean? @default(false)
638
+ documents Json? @default("[]")
577
639
  created_at DateTime @default(now())
578
640
  updated_at DateTime @updatedAt
579
641
 
580
642
  brand EquipmentBrand? @relation(fields: [brand_id], references: [id], onDelete: SetNull)
581
643
  model EquipmentModel? @relation(fields: [model_id], references: [id], onDelete: SetNull)
582
- company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
644
+ company Companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
583
645
  vehicle Vehicle? @relation(fields: [vehicle_id], references: [id], onDelete: SetNull)
584
646
  vehicleLocations VehicleLocation[]
585
647
 
@@ -635,6 +697,7 @@ model DriverLocation {
635
697
  @@index([created_at])
636
698
  @@map("driver_locations")
637
699
  }
700
+
638
701
  // ============================================
639
702
  // FORMS - Form Templates, Fields and Responses
640
703
  // ============================================
@@ -666,23 +729,23 @@ enum FormResponseStatus {
666
729
  }
667
730
 
668
731
  model FormTemplate {
669
- id String @id @default(uuid()) @db.Uuid
670
- name String
732
+ id String @id @default(uuid()) @db.Uuid
733
+ name String
671
734
  description String?
672
- company_id String? @db.Uuid
673
- is_active Boolean @default(true)
674
- is_global Boolean @default(false)
675
- category String?
676
- version Int @default(1)
677
- created_by String? @db.Uuid
678
- created_at DateTime @default(now())
679
- updated_at DateTime @updatedAt
680
-
681
- company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
682
- created_by_user User? @relation(fields: [created_by], references: [id], onDelete: SetNull)
683
- fields TemplateField[]
684
- responses FormResponse[]
685
- forms Form[]
735
+ company_id String? @db.Uuid
736
+ is_active Boolean @default(true)
737
+ is_global Boolean @default(false)
738
+ category String?
739
+ version Int @default(1)
740
+ created_by String? @db.Uuid
741
+ created_at DateTime @default(now())
742
+ updated_at DateTime @updatedAt
743
+
744
+ company Companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
745
+ created_by_user User? @relation(fields: [created_by], references: [id], onDelete: SetNull)
746
+ fields TemplateField[]
747
+ responses FormResponse[]
748
+ forms Form[]
686
749
 
687
750
  @@index([company_id])
688
751
  @@index([is_global])
@@ -692,20 +755,20 @@ model FormTemplate {
692
755
  }
693
756
 
694
757
  model TemplateField {
695
- id String @id @default(uuid()) @db.Uuid
696
- template_id String @db.Uuid
697
- label String
698
- field_type FieldType
699
- placeholder String?
700
- help_text String?
701
- is_required Boolean @default(false)
702
- order Int @default(0)
703
- options Json?
704
- validations Json?
705
- default_value String?
758
+ id String @id @default(uuid()) @db.Uuid
759
+ template_id String @db.Uuid
760
+ label String
761
+ field_type FieldType
762
+ placeholder String?
763
+ help_text String?
764
+ is_required Boolean @default(false)
765
+ order Int @default(0)
766
+ options Json?
767
+ validations Json?
768
+ default_value String?
706
769
  conditional_logic Json?
707
- created_at DateTime @default(now())
708
- updated_at DateTime @updatedAt
770
+ created_at DateTime @default(now())
771
+ updated_at DateTime @updatedAt
709
772
 
710
773
  template FormTemplate @relation(fields: [template_id], references: [id], onDelete: Cascade)
711
774
 
@@ -714,23 +777,23 @@ model TemplateField {
714
777
  }
715
778
 
716
779
  model FormResponse {
717
- id String @id @default(uuid()) @db.Uuid
718
- template_id String? @db.Uuid
719
- form_id String? @db.Uuid
720
- entity_type String
721
- entity_id String @db.Uuid
722
- company_id String? @db.Uuid
723
- respondent_id String? @db.Uuid
724
- responses Json
725
- status FormResponseStatus @default(DRAFT)
726
- submitted_at DateTime?
727
- created_at DateTime @default(now())
728
- updated_at DateTime @updatedAt
729
-
730
- template FormTemplate? @relation(fields: [template_id], references: [id])
731
- form Form? @relation(fields: [form_id], references: [id])
732
- company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
733
- respondent User? @relation(fields: [respondent_id], references: [id], onDelete: SetNull)
780
+ id String @id @default(uuid()) @db.Uuid
781
+ template_id String? @db.Uuid
782
+ form_id String? @db.Uuid
783
+ entity_type String
784
+ entity_id String @db.Uuid
785
+ company_id String? @db.Uuid
786
+ respondent_id String? @db.Uuid
787
+ responses Json
788
+ status FormResponseStatus @default(DRAFT)
789
+ submitted_at DateTime?
790
+ created_at DateTime @default(now())
791
+ updated_at DateTime @updatedAt
792
+
793
+ template FormTemplate? @relation(fields: [template_id], references: [id])
794
+ form Form? @relation(fields: [form_id], references: [id])
795
+ company Companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
796
+ respondent User? @relation(fields: [respondent_id], references: [id], onDelete: SetNull)
734
797
 
735
798
  @@index([template_id])
736
799
  @@index([form_id])
@@ -761,25 +824,25 @@ enum FormStatus {
761
824
  }
762
825
 
763
826
  model Form {
764
- id String @id @default(uuid()) @db.Uuid
765
- name String
827
+ id String @id @default(uuid()) @db.Uuid
828
+ name String
766
829
  description String?
767
- template_id String? @db.Uuid
768
- company_id String? @db.Uuid
830
+ template_id String? @db.Uuid
831
+ company_id String? @db.Uuid
769
832
  target_type FormTargetType
770
- target_ids String[] @db.Uuid
771
- is_required Boolean @default(false)
772
- due_date DateTime?
773
- status FormStatus @default(ACTIVE)
774
- created_by String? @db.Uuid
775
- created_at DateTime @default(now())
776
- updated_at DateTime @updatedAt
777
-
778
- template FormTemplate? @relation(fields: [template_id], references: [id], onDelete: SetNull)
779
- company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
780
- created_by_user User? @relation("FormCreator", fields: [created_by], references: [id], onDelete: SetNull)
781
- fields FormField[]
782
- responses FormResponse[]
833
+ target_ids String[] @db.Uuid
834
+ is_required Boolean @default(false)
835
+ due_date DateTime?
836
+ status FormStatus @default(ACTIVE)
837
+ created_by String? @db.Uuid
838
+ created_at DateTime @default(now())
839
+ updated_at DateTime @updatedAt
840
+
841
+ template FormTemplate? @relation(fields: [template_id], references: [id], onDelete: SetNull)
842
+ company Companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
843
+ created_by_user User? @relation("FormCreator", fields: [created_by], references: [id], onDelete: SetNull)
844
+ fields FormField[]
845
+ responses FormResponse[]
783
846
 
784
847
  @@index([company_id])
785
848
  @@index([template_id])
@@ -790,24 +853,288 @@ model Form {
790
853
  }
791
854
 
792
855
  model FormField {
793
- id String @id @default(uuid()) @db.Uuid
794
- form_id String @db.Uuid
795
- source_field_id String? @db.Uuid
796
- label String
797
- field_type FieldType
798
- placeholder String?
799
- help_text String?
800
- is_required Boolean @default(false)
801
- order Int @default(0)
802
- options Json?
803
- validations Json?
804
- default_value String?
856
+ id String @id @default(uuid()) @db.Uuid
857
+ form_id String @db.Uuid
858
+ source_field_id String? @db.Uuid
859
+ label String
860
+ field_type FieldType
861
+ placeholder String?
862
+ help_text String?
863
+ is_required Boolean @default(false)
864
+ order Int @default(0)
865
+ options Json?
866
+ validations Json?
867
+ default_value String?
805
868
  conditional_logic Json?
806
- created_at DateTime @default(now())
807
- updated_at DateTime @updatedAt
869
+ created_at DateTime @default(now())
870
+ updated_at DateTime @updatedAt
808
871
 
809
872
  form Form @relation(fields: [form_id], references: [id], onDelete: Cascade)
810
873
 
811
874
  @@index([form_id])
812
875
  @@map("form_fields")
813
876
  }
877
+
878
+ model VehicleType {
879
+ id String @id @default(uuid()) @db.Uuid
880
+ name String @unique
881
+ description String?
882
+ is_active Boolean @default(true)
883
+ created_at DateTime @default(now())
884
+ updated_at DateTime @updatedAt
885
+
886
+ vehicles Vehicle[]
887
+ tenderVehicles TenderVehicle[]
888
+
889
+ @@map("vehicle_types")
890
+ }
891
+
892
+ model VehicleEquipment {
893
+ id String @id @default(uuid()) @db.Uuid
894
+ name String @unique
895
+
896
+ tenderVehicleEquipments TenderVehicleEquipment[]
897
+
898
+ @@map("vehicle_equipments")
899
+ }
900
+
901
+ model Tender {
902
+ id String @id @default(uuid()) @db.Uuid
903
+ title String
904
+ description String?
905
+ status TenderStatus @default(DRAFT)
906
+ tender_type TenderType @default(FIXED_PRICE_TENDER)
907
+ tender_mode TenderMode @default(PUBLIC)
908
+ budget Float?
909
+ currency String? @default("USD")
910
+ user_id String @db.Uuid
911
+ company_id String @db.Uuid
912
+ order_id String? @db.Uuid
913
+ trip_type TripType @default(NATIONAL)
914
+ expiration_date DateTime
915
+ terms_and_conditions Json?
916
+ created_at DateTime @default(now())
917
+ updated_at DateTime @updatedAt
918
+
919
+ user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
920
+ company Companies @relation(fields: [company_id], references: [id], onDelete: Cascade)
921
+ order Order? @relation(fields: [order_id], references: [id], onDelete: SetNull)
922
+ tenderVehicles TenderVehicle[]
923
+ tenderChats TenderChat[]
924
+ tenderNotifications TenderNotification[]
925
+ tenderLocationNotifications TenderLocationNotification[]
926
+
927
+ @@index([user_id])
928
+ @@index([company_id])
929
+ @@index([order_id])
930
+ @@map("tenders")
931
+ }
932
+
933
+ model TenderVehicle {
934
+ id String @id @default(uuid()) @db.Uuid
935
+ tender_id String @db.Uuid
936
+ vehicle_type_id String @db.Uuid
937
+ quantity Int @default(1)
938
+ min_weight_capacity Float?
939
+ weight_unit WeightUnits @default(KG)
940
+ min_volume_capacity Float?
941
+ dimension_unit DimensionUnits @default(MT)
942
+ min_year Int?
943
+ pickup_datetime DateTime?
944
+ delivery_datetime DateTime?
945
+ pickup_instructions String?
946
+ delivery_instructions String?
947
+ budget_per_vehicle Float?
948
+ currency String? @default("USD")
949
+ is_negotiable Boolean @default(false)
950
+ created_at DateTime @default(now())
951
+ updated_at DateTime @updatedAt
952
+
953
+ tender Tender @relation(fields: [tender_id], references: [id], onDelete: Cascade)
954
+ vehicle_type VehicleType @relation(fields: [vehicle_type_id], references: [id], onDelete: Cascade)
955
+ tenderVehicleEquipments TenderVehicleEquipment[]
956
+ tenderApplications TenderApplication[]
957
+
958
+ @@index([tender_id])
959
+ @@index([vehicle_type_id])
960
+ @@map("tender_vehicles")
961
+ }
962
+
963
+ model TenderVehicleEquipment {
964
+ id String @id @default(uuid()) @db.Uuid
965
+ tender_vehicle_id String @db.Uuid
966
+ vehicle_equipment_id String @db.Uuid
967
+ created_at DateTime @default(now())
968
+ updated_at DateTime @updatedAt
969
+
970
+ tender_vehicle TenderVehicle @relation(fields: [tender_vehicle_id], references: [id], onDelete: Cascade)
971
+ vehicle_equipment VehicleEquipment @relation(fields: [vehicle_equipment_id], references: [id], onDelete: Cascade)
972
+
973
+ @@index([tender_vehicle_id])
974
+ @@index([vehicle_equipment_id])
975
+ @@map("tender_vehicle_equipments")
976
+ }
977
+
978
+ model TenderChat {
979
+ id String @id @default(uuid()) @db.Uuid
980
+ tender_id String @db.Uuid
981
+ user_sends_id String @db.Uuid
982
+ user_receives_id String @db.Uuid
983
+ message String
984
+ created_at DateTime @default(now())
985
+
986
+ tender Tender @relation(fields: [tender_id], references: [id], onDelete: Cascade)
987
+ user_sends User @relation("TenderChatSender", fields: [user_sends_id], references: [id], onDelete: Cascade)
988
+ user_receives User @relation("TenderChatReceiver", fields: [user_receives_id], references: [id], onDelete: Cascade)
989
+
990
+ @@map("tender_chats")
991
+ }
992
+
993
+ model TenderApplication {
994
+ id String @id @default(uuid()) @db.Uuid
995
+ status ApplicationStatus @default(PENDING)
996
+ tender_vehicle_id String @db.Uuid
997
+ vehicle_id String @db.Uuid
998
+ user_id String @db.Uuid
999
+ updated_user_id String? @db.Uuid
1000
+ accepts_terms_conditions Boolean @default(false)
1001
+ postulated_price Float?
1002
+ currency String? @default("USD")
1003
+ created_at DateTime @default(now())
1004
+ updated_at DateTime @updatedAt
1005
+ edit_limit DateTime?
1006
+
1007
+ tender_vehicle TenderVehicle @relation(fields: [tender_vehicle_id], references: [id], onDelete: Cascade)
1008
+ vehicle Vehicle @relation(fields: [vehicle_id], references: [id], onDelete: Cascade)
1009
+ user User @relation("ApplicantUser", fields: [user_id], references: [id], onDelete: Cascade)
1010
+ updated_user User? @relation("UpdaterUser", fields: [updated_user_id], references: [id], onDelete: SetNull)
1011
+
1012
+ @@index([tender_vehicle_id])
1013
+ @@index([vehicle_id])
1014
+ @@index([user_id])
1015
+ @@index([status])
1016
+ @@map("tender_applications")
1017
+ }
1018
+
1019
+ model Group {
1020
+ id String @id @default(uuid()) @db.Uuid
1021
+ name String
1022
+ company_id String @db.Uuid
1023
+ created_at DateTime @default(now())
1024
+ updated_at DateTime @updatedAt
1025
+
1026
+ company Companies @relation(fields: [company_id], references: [id], onDelete: Cascade)
1027
+
1028
+ userGroups UserGroup[]
1029
+ tenderNotifications TenderNotification[]
1030
+
1031
+ @@map("groups")
1032
+ }
1033
+
1034
+ model UserGroup {
1035
+ id String @id @default(uuid()) @db.Uuid
1036
+ user_id String @db.Uuid
1037
+ group_id String @db.Uuid
1038
+ created_at DateTime @default(now())
1039
+ updated_at DateTime @updatedAt
1040
+
1041
+ user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
1042
+ group Group @relation(fields: [group_id], references: [id], onDelete: Cascade)
1043
+
1044
+ @@unique([user_id, group_id])
1045
+ @@index([user_id])
1046
+ @@index([group_id])
1047
+ @@map("user_groups")
1048
+ }
1049
+
1050
+ model TenderNotification {
1051
+ id String @id @default(uuid()) @db.Uuid
1052
+ tender_id String @db.Uuid
1053
+ user_id String? @db.Uuid
1054
+ group_id String? @db.Uuid
1055
+ whatsapp Boolean @default(false)
1056
+ email Boolean @default(false)
1057
+ push Boolean @default(false)
1058
+ message String
1059
+ created_at DateTime @default(now())
1060
+
1061
+ tender Tender @relation(fields: [tender_id], references: [id], onDelete: Cascade)
1062
+ user User? @relation(fields: [user_id], references: [id], onDelete: Cascade)
1063
+ group Group? @relation(fields: [group_id], references: [id], onDelete: Cascade)
1064
+
1065
+ @@index([tender_id])
1066
+ @@index([user_id])
1067
+ @@index([group_id])
1068
+ @@map("tender_notifications")
1069
+ }
1070
+
1071
+ model Location {
1072
+ id String @id @default(uuid()) @db.Uuid
1073
+ title String
1074
+ location_type LocationType
1075
+ country_code String
1076
+ zip_code String?
1077
+ geom Unsupported("geography(Point, 4326)")
1078
+ geofence Unsupported("geography(MultiPolygon, 4326)")?
1079
+
1080
+ created_at DateTime @default(now())
1081
+ updated_at DateTime @updatedAt
1082
+ companyLocations CompanyLocation[]
1083
+ tenderLocationNotifications TenderLocationNotification[]
1084
+
1085
+ @@index([title])
1086
+ @@index([location_type])
1087
+ @@index([country_code])
1088
+ @@index([zip_code])
1089
+ @@map("locations")
1090
+ }
1091
+
1092
+ model CompanyLocation {
1093
+ id String @id @default(uuid()) @db.Uuid
1094
+ company_id String @db.Uuid
1095
+ location_id String @db.Uuid
1096
+ is_active Boolean @default(true)
1097
+
1098
+ created_at DateTime @default(now())
1099
+ updated_at DateTime @updatedAt
1100
+
1101
+ company Companies @relation(fields: [company_id], references: [id], onDelete: Cascade)
1102
+ location Location @relation(fields: [location_id], references: [id], onDelete: Cascade)
1103
+
1104
+ @@unique([company_id, location_id])
1105
+ @@index([company_id])
1106
+ @@index([location_id])
1107
+ @@map("company_locations")
1108
+ }
1109
+
1110
+ model TenderLocationNotification {
1111
+ id String @id @default(uuid()) @db.Uuid
1112
+ tender_id String @db.Uuid
1113
+ location_id String @db.Uuid
1114
+
1115
+ created_at DateTime @default(now())
1116
+ updated_at DateTime @updatedAt
1117
+
1118
+ tender Tender @relation(fields: [tender_id], references: [id], onDelete: Cascade)
1119
+ location Location @relation(fields: [location_id], references: [id], onDelete: Cascade)
1120
+
1121
+ @@index([tender_id])
1122
+ @@index([location_id])
1123
+ @@map("tender_location_notifications")
1124
+ }
1125
+
1126
+ model RegularSupplier {
1127
+ id String @id @default(uuid()) @db.Uuid
1128
+ company_id String @db.Uuid
1129
+ supplier_id String @db.Uuid
1130
+ created_at DateTime @default(now())
1131
+ updated_at DateTime @updatedAt
1132
+
1133
+ company Companies @relation(fields: [company_id], references: [id], onDelete: Cascade)
1134
+ supplier Companies @relation("SupplierCompany", fields: [supplier_id], references: [id], onDelete: Cascade)
1135
+
1136
+ @@unique([company_id, supplier_id])
1137
+ @@index([company_id])
1138
+ @@index([supplier_id])
1139
+ @@map("regular_suppliers")
1140
+ }