@spytecgps/nova-orm 1.4.168 → 1.4.170

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.
package/schema.sql ADDED
@@ -0,0 +1,3388 @@
1
+ -- nova-orm-schema-checksum: ae0689372d74db46ba7553d50dad2b02
2
+ -- Nova ORM Schema Dump
3
+ -- Generated at: 2026-02-09T13:45:21.597Z
4
+
5
+ SET FOREIGN_KEY_CHECKS = 0;
6
+
7
+ DROP TABLE IF EXISTS `acumaticaAmazonProduct`;
8
+ CREATE TABLE `acumaticaAmazonProduct` (
9
+ `id` bigint NOT NULL AUTO_INCREMENT,
10
+ `sku` varchar(50) NOT NULL,
11
+ `asin` varchar(50) NOT NULL,
12
+ `description` varchar(500) DEFAULT NULL,
13
+ `reviewUrl` varchar(1000) DEFAULT NULL,
14
+ `productUrl` varchar(1000) DEFAULT NULL,
15
+ PRIMARY KEY (`id`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
17
+
18
+ DROP TABLE IF EXISTS `acumaticaImeiIccidData`;
19
+ CREATE TABLE `acumaticaImeiIccidData` (
20
+ `id` bigint NOT NULL AUTO_INCREMENT,
21
+ `imei` varchar(50) NOT NULL,
22
+ `iccid` varchar(50) DEFAULT NULL,
23
+ `amazonShipmentId` varchar(50) DEFAULT NULL,
24
+ `deviceModel` varchar(50) DEFAULT NULL,
25
+ `deviceCarrier` varchar(50) DEFAULT NULL,
26
+ `carrierNetwork` varchar(50) DEFAULT NULL,
27
+ `carrierProductId` varchar(50) DEFAULT NULL,
28
+ `poNbr` varchar(50) DEFAULT NULL,
29
+ `createdBy` varchar(100) DEFAULT NULL,
30
+ `createdDate` varchar(50) DEFAULT NULL,
31
+ `lastModifiedDate` varchar(50) DEFAULT NULL,
32
+ `shipDate` varchar(50) DEFAULT NULL,
33
+ `asin` varchar(50) DEFAULT NULL,
34
+ `countryCode` varchar(3) DEFAULT NULL,
35
+ `platform` varchar(100) DEFAULT NULL,
36
+ `listingId` varchar(100) DEFAULT NULL,
37
+ `location` varchar(100) DEFAULT NULL,
38
+ PRIMARY KEY (`id`),
39
+ KEY `ixAcumaticaImeiIccidDataAmazonShipmentId` (`amazonShipmentId`),
40
+ KEY `ixAcumaticaImeiIccidDataImei` (`imei`),
41
+ KEY `ixAcumaticaImeiIccidDataIccid` (`iccid`)
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
43
+
44
+ DROP TABLE IF EXISTS `acumaticaOrderShipmentDetails`;
45
+ CREATE TABLE `acumaticaOrderShipmentDetails` (
46
+ `id` bigint NOT NULL AUTO_INCREMENT,
47
+ `imei` varchar(255) DEFAULT NULL,
48
+ `shipmentNumber` varchar(50) DEFAULT NULL,
49
+ `shipmentStatus` varchar(50) DEFAULT NULL,
50
+ `shipmentDate` datetime DEFAULT NULL,
51
+ `orderType` varchar(10) DEFAULT NULL,
52
+ `orderStatus` varchar(50) DEFAULT NULL,
53
+ `iccid` varchar(255) DEFAULT NULL,
54
+ `sku` varchar(50) DEFAULT NULL,
55
+ PRIMARY KEY (`id`),
56
+ KEY `ixAcumaticaOrderShipmentDetails_imei_shipmentDate` (`imei`,`shipmentDate`)
57
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
58
+
59
+ DROP TABLE IF EXISTS `acumaticaShipment`;
60
+ CREATE TABLE `acumaticaShipment` (
61
+ `shipmentId` varchar(50) NOT NULL,
62
+ `shipmentDate` datetime DEFAULT NULL,
63
+ `location` varchar(6) DEFAULT NULL,
64
+ PRIMARY KEY (`shipmentId`)
65
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
66
+
67
+ DROP TABLE IF EXISTS `acumaticaShipmentAmazon`;
68
+ CREATE TABLE `acumaticaShipmentAmazon` (
69
+ `shipmentId` varchar(50) NOT NULL,
70
+ `asin` varchar(50) NOT NULL,
71
+ PRIMARY KEY (`shipmentId`,`asin`)
72
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
73
+
74
+ DROP TABLE IF EXISTS `aempToken`;
75
+ CREATE TABLE `aempToken` (
76
+ `id` int NOT NULL AUTO_INCREMENT,
77
+ `clientId` int NOT NULL,
78
+ `token` binary(16) NOT NULL,
79
+ `createdAt` datetime DEFAULT NULL,
80
+ `updatedAt` datetime DEFAULT NULL,
81
+ `expiresAt` datetime DEFAULT NULL,
82
+ PRIMARY KEY (`id`),
83
+ UNIQUE KEY `ixuAempToken_Token` (`token`)
84
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
85
+
86
+ DROP TABLE IF EXISTS `airflowAcumaticaExportImeiIccidData`;
87
+ CREATE TABLE `airflowAcumaticaExportImeiIccidData` (
88
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT,
89
+ `amazonShipmentID` varchar(50) NOT NULL,
90
+ `imei` varchar(50) NOT NULL,
91
+ `iccid` varchar(500) DEFAULT NULL,
92
+ `deviceModel` varchar(1000) DEFAULT NULL,
93
+ `deviceCarrier` varchar(1000) DEFAULT NULL,
94
+ `carrierNetwork` varchar(1000) DEFAULT NULL,
95
+ `carrierProductId` varchar(1000) DEFAULT NULL,
96
+ `poNumber` varchar(1000) DEFAULT NULL,
97
+ `createdBy` varchar(1000) DEFAULT NULL,
98
+ `createdDate` varchar(1000) DEFAULT NULL,
99
+ `lastModifiedDate` varchar(1000) DEFAULT NULL,
100
+ `shipDate` varchar(1000) DEFAULT NULL,
101
+ `platform` varchar(1000) DEFAULT NULL,
102
+ `asin` varchar(1000) DEFAULT NULL,
103
+ `listingId` varchar(1000) DEFAULT NULL,
104
+ `location` varchar(1000) DEFAULT NULL,
105
+ PRIMARY KEY (`id`)
106
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
107
+
108
+ DROP TABLE IF EXISTS `airflowAcumaticaExportOrderShipmentDetails`;
109
+ CREATE TABLE `airflowAcumaticaExportOrderShipmentDetails` (
110
+ `id` bigint NOT NULL AUTO_INCREMENT,
111
+ `customer` varchar(50) NOT NULL,
112
+ `orderType` varchar(50) NOT NULL,
113
+ `orderNumber` varchar(50) NOT NULL,
114
+ `customerOrderNumber` varchar(50) NOT NULL,
115
+ `orderDate` varchar(50) NOT NULL,
116
+ `orderedQty` varchar(50) NOT NULL,
117
+ `orderTotal` varchar(50) NOT NULL,
118
+ `orderStatus` varchar(50) NOT NULL,
119
+ `currency` varchar(50) NOT NULL,
120
+ `createdBy` varchar(50) NOT NULL,
121
+ `createdOn` varchar(50) NOT NULL,
122
+ `lastModifiedBy` varchar(50) NOT NULL,
123
+ `lastModifiedOn` varchar(50) NOT NULL,
124
+ `shipmentStatus` varchar(50) NOT NULL,
125
+ `shipVia` varchar(50) NOT NULL,
126
+ `shipmentNumber` varchar(50) NOT NULL,
127
+ `shipmentDate` varchar(50) NOT NULL,
128
+ `inventoryId` varchar(50) NOT NULL,
129
+ `gpsDeviceQty` varchar(50) NOT NULL,
130
+ `shiplineQty` varchar(50) NOT NULL,
131
+ `lotSerialNumber` varchar(512) NOT NULL,
132
+ `warehouse` varchar(50) NOT NULL,
133
+ `location` varchar(50) NOT NULL,
134
+ `carrier` varchar(50) NOT NULL,
135
+ `iccid` varchar(50) NOT NULL,
136
+ PRIMARY KEY (`id`)
137
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
138
+
139
+ DROP TABLE IF EXISTS `airflowAcumaticaShipmentsAmazon`;
140
+ CREATE TABLE `airflowAcumaticaShipmentsAmazon` (
141
+ `id` bigint NOT NULL AUTO_INCREMENT,
142
+ `shipment` varchar(50) DEFAULT NULL,
143
+ `date` varchar(50) DEFAULT NULL,
144
+ `asin` varchar(50) DEFAULT NULL,
145
+ `location` varchar(50) DEFAULT NULL,
146
+ PRIMARY KEY (`id`)
147
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
148
+
149
+ DROP TABLE IF EXISTS `alert`;
150
+ CREATE TABLE `alert` (
151
+ `id` bigint NOT NULL AUTO_INCREMENT,
152
+ `alertTypeId` smallint NOT NULL,
153
+ `value` varchar(5000) DEFAULT NULL,
154
+ `createdAt` datetime(3) NOT NULL,
155
+ `userId` binary(16) DEFAULT NULL,
156
+ `messageId` binary(16) NOT NULL,
157
+ `boundaryId` int DEFAULT NULL,
158
+ `imei` varchar(15) NOT NULL,
159
+ `sendTime` datetime(3) NOT NULL,
160
+ `lat` decimal(8,6) DEFAULT NULL,
161
+ `lon` decimal(9,6) DEFAULT NULL,
162
+ `address` varchar(255) DEFAULT NULL,
163
+ `clientId` int DEFAULT NULL,
164
+ `isBuffer` tinyint(1) DEFAULT NULL,
165
+ `isNotification` tinyint(1) DEFAULT NULL,
166
+ `gpsUtcTime` datetime(3) DEFAULT NULL,
167
+ `relevantAddress` varchar(255) DEFAULT NULL,
168
+ `gpsMessageId` binary(16) DEFAULT NULL,
169
+ `cellTowerRelevantAddress` varchar(255) DEFAULT NULL,
170
+ `userAlertConfigurationId` int DEFAULT NULL,
171
+ `clientAlertConfigurationId` int DEFAULT NULL,
172
+ `deleted` tinyint(1) DEFAULT '0',
173
+ PRIMARY KEY (`id`),
174
+ KEY `ixAlertSendTime` (`sendTime`),
175
+ KEY `ixAlertImei` (`imei`),
176
+ KEY `ixAlertUserId_AlertTypeId_SendTime` (`userId`,`alertTypeId`,`sendTime`),
177
+ KEY `ixAlertUserId_Imei_AlertTypeId_SendTime` (`userId`,`imei`,`alertTypeId`,`sendTime`)
178
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
179
+
180
+ DROP TABLE IF EXISTS `alertType`;
181
+ CREATE TABLE `alertType` (
182
+ `id` smallint NOT NULL AUTO_INCREMENT,
183
+ `name` varchar(50) NOT NULL,
184
+ `title` varchar(255) DEFAULT NULL,
185
+ `description` varchar(2000) DEFAULT NULL,
186
+ `isSystem` tinyint(1) NOT NULL DEFAULT '0',
187
+ `icon` varchar(50) DEFAULT NULL,
188
+ `context` varchar(25) DEFAULT NULL,
189
+ `identifier` varchar(50) DEFAULT NULL,
190
+ `stage` varchar(10) DEFAULT NULL,
191
+ `category` varchar(25) DEFAULT NULL,
192
+ `key` varchar(50) DEFAULT NULL,
193
+ `createdAt` datetime DEFAULT NULL,
194
+ PRIMARY KEY (`id`),
195
+ KEY `ixAlertTypeStage` (`stage`)
196
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
197
+
198
+ DROP TABLE IF EXISTS `appFeatureType`;
199
+ CREATE TABLE `appFeatureType` (
200
+ `id` int NOT NULL AUTO_INCREMENT,
201
+ `name` varchar(100) NOT NULL,
202
+ `description` varchar(500) NOT NULL,
203
+ `statusId` int NOT NULL DEFAULT '1',
204
+ PRIMARY KEY (`id`)
205
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
206
+
207
+ DROP TABLE IF EXISTS `asinPromotion`;
208
+ CREATE TABLE `asinPromotion` (
209
+ `asin` varchar(15) NOT NULL,
210
+ `promotionId` int NOT NULL,
211
+ PRIMARY KEY (`asin`,`promotionId`)
212
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
213
+
214
+ DROP TABLE IF EXISTS `assetCategory`;
215
+ CREATE TABLE `assetCategory` (
216
+ `id` tinyint NOT NULL AUTO_INCREMENT,
217
+ `name` varchar(50) NOT NULL,
218
+ `description` varchar(255) DEFAULT NULL,
219
+ PRIMARY KEY (`id`),
220
+ UNIQUE KEY `ixuAssetCategoryName` (`name`)
221
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
222
+
223
+ DROP TABLE IF EXISTS `assetProfile`;
224
+ CREATE TABLE `assetProfile` (
225
+ `id` int NOT NULL AUTO_INCREMENT,
226
+ `deviceId` int DEFAULT NULL,
227
+ `name` varchar(50) DEFAULT NULL,
228
+ `clientId` int NOT NULL,
229
+ `assetProfileTypeId` smallint DEFAULT NULL,
230
+ `make` varchar(50) DEFAULT NULL,
231
+ `model` varchar(50) DEFAULT NULL,
232
+ `serialNumber` varchar(50) DEFAULT NULL,
233
+ `year` smallint DEFAULT NULL,
234
+ `status` varchar(50) NOT NULL DEFAULT 'Active',
235
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
236
+ `modifiedAt` datetime DEFAULT NULL,
237
+ PRIMARY KEY (`id`),
238
+ UNIQUE KEY `ix_deviceId` (`deviceId`),
239
+ KEY `ix_clientId` (`clientId`)
240
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
241
+
242
+ DROP TABLE IF EXISTS `assetProfileCategory`;
243
+ CREATE TABLE `assetProfileCategory` (
244
+ `id` tinyint NOT NULL AUTO_INCREMENT,
245
+ `name` varchar(50) NOT NULL,
246
+ PRIMARY KEY (`id`),
247
+ UNIQUE KEY `ixuAssetProfileCategoryName` (`name`)
248
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
249
+
250
+ DROP TABLE IF EXISTS `assetProfileCustomField`;
251
+ CREATE TABLE `assetProfileCustomField` (
252
+ `id` int NOT NULL AUTO_INCREMENT,
253
+ `assetProfileId` int NOT NULL,
254
+ `name` varchar(50) NOT NULL,
255
+ `value` varchar(50) NOT NULL,
256
+ `type` varchar(50) NOT NULL,
257
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
258
+ PRIMARY KEY (`id`),
259
+ KEY `ix_assetProfileId` (`assetProfileId`)
260
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
261
+
262
+ DROP TABLE IF EXISTS `assetProfileCustomStatus`;
263
+ CREATE TABLE `assetProfileCustomStatus` (
264
+ `id` int NOT NULL AUTO_INCREMENT,
265
+ `clientId` int NOT NULL,
266
+ `status` varchar(50) NOT NULL,
267
+ `label` varchar(50) NOT NULL,
268
+ `description` varchar(255) NOT NULL,
269
+ `color` varchar(25) NOT NULL,
270
+ PRIMARY KEY (`id`),
271
+ UNIQUE KEY `ix_clientId_status` (`clientId`,`status`)
272
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
273
+
274
+ DROP TABLE IF EXISTS `assetProfileMedia`;
275
+ CREATE TABLE `assetProfileMedia` (
276
+ `id` int NOT NULL AUTO_INCREMENT,
277
+ `assetProfileId` int NOT NULL,
278
+ `mediaType` varchar(15) NOT NULL COMMENT 'The type of the media: image or document',
279
+ `fileName` varchar(255) NOT NULL,
280
+ `fileExtension` varchar(15) DEFAULT NULL,
281
+ `s3FilesPath` varchar(255) DEFAULT NULL,
282
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
283
+ PRIMARY KEY (`id`),
284
+ UNIQUE KEY `ixu_ix_assetProfileId_fileName` (`assetProfileId`,`fileName`)
285
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
286
+
287
+ DROP TABLE IF EXISTS `assetProfileNote`;
288
+ CREATE TABLE `assetProfileNote` (
289
+ `id` int NOT NULL AUTO_INCREMENT,
290
+ `assetProfileId` int NOT NULL,
291
+ `note` varchar(255) NOT NULL,
292
+ `userId` binary(16) NOT NULL,
293
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
294
+ PRIMARY KEY (`id`),
295
+ KEY `ix_assetProfileId` (`assetProfileId`)
296
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
297
+
298
+ DROP TABLE IF EXISTS `assetProfileType`;
299
+ CREATE TABLE `assetProfileType` (
300
+ `id` smallint NOT NULL AUTO_INCREMENT,
301
+ `name` varchar(50) NOT NULL,
302
+ `assetProfileCategoryId` tinyint NOT NULL,
303
+ `clientId` int DEFAULT NULL,
304
+ PRIMARY KEY (`id`),
305
+ UNIQUE KEY `ixu_assetProfileCategoryId_name_clientId` (`assetProfileCategoryId`,`name`,`clientId`)
306
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
307
+
308
+ DROP TABLE IF EXISTS `avalaraExemptCert`;
309
+ CREATE TABLE `avalaraExemptCert` (
310
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
311
+ `clientId` int NOT NULL,
312
+ `fileName` varchar(1000) NOT NULL,
313
+ `expirationDate` date NOT NULL,
314
+ `createdAt` datetime NOT NULL,
315
+ PRIMARY KEY (`id`),
316
+ UNIQUE KEY `IDX_0fa6a1061b4cb7238164321492` (`clientId`)
317
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
318
+
319
+ DROP TABLE IF EXISTS `avalaraQueue`;
320
+ CREATE TABLE `avalaraQueue` (
321
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
322
+ `subscriptionId` varchar(256) DEFAULT NULL,
323
+ `planId` varchar(256) DEFAULT NULL,
324
+ `priceIncrease` decimal(19,4) DEFAULT NULL,
325
+ `priceDecrease` decimal(19,4) DEFAULT NULL,
326
+ `status` tinyint(1) NOT NULL DEFAULT '0',
327
+ `basePrice` enum('original','calculated') DEFAULT NULL,
328
+ `attempts` tinyint NOT NULL DEFAULT '0',
329
+ `createdAt` datetime NOT NULL,
330
+ PRIMARY KEY (`id`),
331
+ KEY `ixAvalaraQueueSubscriptionId` (`subscriptionId`)
332
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
333
+
334
+ DROP TABLE IF EXISTS `beaconBleMesh`;
335
+ CREATE TABLE `beaconBleMesh` (
336
+ `id` int NOT NULL AUTO_INCREMENT,
337
+ `clientId` int NOT NULL,
338
+ `name` varchar(250) DEFAULT NULL,
339
+ `bleMac` varchar(20) NOT NULL,
340
+ `bleMeshId` int DEFAULT NULL,
341
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
342
+ PRIMARY KEY (`id`),
343
+ UNIQUE KEY `ixuBeaconMesh_bleMac` (`bleMac`),
344
+ KEY `ixBeaconMesh_clientId` (`clientId`)
345
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
346
+
347
+ DROP TABLE IF EXISTS `billing`;
348
+ CREATE TABLE `billing` (
349
+ `id` int NOT NULL AUTO_INCREMENT,
350
+ `deviceId` int DEFAULT NULL,
351
+ `imei` varchar(15) DEFAULT NULL,
352
+ `planId` varchar(50) DEFAULT NULL,
353
+ `subscriptionId` varchar(50) DEFAULT NULL,
354
+ `platform` varchar(25) DEFAULT NULL,
355
+ `status` varchar(25) DEFAULT NULL,
356
+ `createdAt` datetime DEFAULT NULL,
357
+ `updatedAt` datetime DEFAULT NULL,
358
+ `subscriptionValue` decimal(19,4) DEFAULT NULL,
359
+ `subscriptionPeriodMonths` tinyint DEFAULT NULL,
360
+ `subscriptionValueMonthly` decimal(19,4) DEFAULT NULL,
361
+ `clientId` int DEFAULT NULL,
362
+ PRIMARY KEY (`id`),
363
+ UNIQUE KEY `ixuBillingImei` (`imei`),
364
+ KEY `ixBillingCreatedAt` (`createdAt`),
365
+ KEY `ixBillingComposite` (`imei`,`subscriptionId`,`platform`,`status`,`planId`),
366
+ KEY `ixBillingSubscriptionId` (`subscriptionId`),
367
+ KEY `ixBillingPlanId` (`planId`),
368
+ KEY `ixBillingClientId` (`clientId`)
369
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
370
+
371
+ DROP TABLE IF EXISTS `billingCampaign`;
372
+ CREATE TABLE `billingCampaign` (
373
+ `id` int NOT NULL AUTO_INCREMENT,
374
+ `type` varchar(64) NOT NULL,
375
+ `enabled` tinyint(1) NOT NULL DEFAULT '0',
376
+ `startAt` datetime DEFAULT NULL,
377
+ `endAt` datetime DEFAULT NULL,
378
+ `createdAt` datetime DEFAULT NULL,
379
+ `updatedAt` datetime DEFAULT NULL,
380
+ PRIMARY KEY (`id`),
381
+ UNIQUE KEY `ixuBillingCampaignType` (`type`)
382
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
383
+
384
+ DROP TABLE IF EXISTS `billingCampaignFreeOffer`;
385
+ CREATE TABLE `billingCampaignFreeOffer` (
386
+ `id` int NOT NULL AUTO_INCREMENT,
387
+ `offerId` int NOT NULL,
388
+ `subscriptionId` varchar(255) DEFAULT NULL,
389
+ `email` varchar(255) DEFAULT NULL,
390
+ `imei` varchar(64) DEFAULT NULL,
391
+ `clientId` int DEFAULT NULL,
392
+ `type` enum('discount','deferral') DEFAULT NULL,
393
+ `status` enum('applied','completed','canceled_before','canceled_during') DEFAULT NULL,
394
+ `discountPrice` decimal(19,4) DEFAULT NULL,
395
+ `discountDurationMonths` int DEFAULT NULL,
396
+ `deferralMonths` int DEFAULT NULL,
397
+ `originalRenewalDate` date DEFAULT NULL,
398
+ `newRenewalDate` date DEFAULT NULL,
399
+ `freeMonthStartAt` datetime DEFAULT NULL,
400
+ `freeMonthEndAt` datetime DEFAULT NULL,
401
+ `appliedAt` datetime DEFAULT NULL,
402
+ `completedAt` datetime DEFAULT NULL,
403
+ `canceledAt` datetime DEFAULT NULL,
404
+ `createdAt` datetime DEFAULT NULL,
405
+ `updatedAt` datetime DEFAULT NULL,
406
+ PRIMARY KEY (`id`),
407
+ KEY `ixBillingCampaignFreeOfferClientIdAppliedAt` (`clientId`,`appliedAt`),
408
+ KEY `ixBillingCampaignFreeOfferImei` (`imei`),
409
+ KEY `ixBillingCampaignFreeOfferSubscriptionId` (`subscriptionId`)
410
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
411
+
412
+ DROP TABLE IF EXISTS `billingCampaignFreeTrial`;
413
+ CREATE TABLE `billingCampaignFreeTrial` (
414
+ `id` int NOT NULL AUTO_INCREMENT,
415
+ `offerId` int NOT NULL,
416
+ `subscriptionId` varchar(255) DEFAULT NULL,
417
+ `email` varchar(255) DEFAULT NULL,
418
+ `imei` varchar(64) DEFAULT NULL,
419
+ `status` enum('in_trial','canceled','converted','overdue') DEFAULT NULL,
420
+ `trialLengthHours` int DEFAULT NULL,
421
+ `trialStartAt` datetime DEFAULT NULL,
422
+ `trialEndAt` datetime DEFAULT NULL,
423
+ `convertedAt` datetime DEFAULT NULL,
424
+ `canceledAt` datetime DEFAULT NULL,
425
+ `reminderSent` tinyint(1) NOT NULL DEFAULT '0',
426
+ `modalShown` tinyint(1) NOT NULL DEFAULT '0',
427
+ `retryAttemptCount` int NOT NULL DEFAULT '0',
428
+ `createdAt` datetime DEFAULT NULL,
429
+ `updatedAt` datetime DEFAULT NULL,
430
+ PRIMARY KEY (`id`),
431
+ KEY `ixBillingCampaignFreeTrialSubscriptionId` (`subscriptionId`),
432
+ KEY `ixBillingCampaignFreeTrialCreatedAt` (`createdAt`),
433
+ KEY `ixBillingCampaignFreeTrialOfferId` (`offerId`),
434
+ KEY `ixBillingCampaignFreeTrialStatusTrialEndAt` (`status`,`trialEndAt`),
435
+ KEY `ixBillingCampaignFreeTrialEmail` (`email`),
436
+ KEY `ixBillingCampaignFreeTrialImei` (`imei`)
437
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
438
+
439
+ DROP TABLE IF EXISTS `billingCampaignPrepaid`;
440
+ CREATE TABLE `billingCampaignPrepaid` (
441
+ `id` int NOT NULL AUTO_INCREMENT,
442
+ `offerId` int NOT NULL,
443
+ `subscriptionId` varchar(255) DEFAULT NULL,
444
+ `email` varchar(255) DEFAULT NULL,
445
+ `imei` varchar(64) DEFAULT NULL,
446
+ `status` enum('prepaid_started','prepaid_ending_soon','prepaid_converted','canceled','overdue') DEFAULT NULL,
447
+ `prepaidDurationMonths` int DEFAULT NULL,
448
+ `prepaidStartAt` datetime DEFAULT NULL,
449
+ `prepaidEndAt` datetime DEFAULT NULL,
450
+ `convertedAt` datetime DEFAULT NULL,
451
+ `canceledAt` datetime DEFAULT NULL,
452
+ `annualUpsellEligible` tinyint(1) NOT NULL DEFAULT '0',
453
+ `annualUpsellImpressions` int NOT NULL DEFAULT '0',
454
+ `annualUpsellFirstShownAt` datetime DEFAULT NULL,
455
+ `annualUpsellLastShownAt` datetime DEFAULT NULL,
456
+ `annualUpsellDismissedCount` int NOT NULL DEFAULT '0',
457
+ `annualUpsellUpgradedAt` datetime DEFAULT NULL,
458
+ `createdAt` datetime DEFAULT NULL,
459
+ `updatedAt` datetime DEFAULT NULL,
460
+ PRIMARY KEY (`id`),
461
+ KEY `ixBillingCampaignPrepaidCreatedAt` (`createdAt`),
462
+ KEY `ixBillingCampaignPrepaidOfferId` (`offerId`),
463
+ KEY `ixBillingCampaignPrepaidStatusPrepaidEndAt` (`status`,`prepaidEndAt`),
464
+ KEY `ixBillingCampaignPrepaidEmail` (`email`),
465
+ KEY `ixBillingCampaignPrepaidImei` (`imei`)
466
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
467
+
468
+ DROP TABLE IF EXISTS `billingCustomerAmazon`;
469
+ CREATE TABLE `billingCustomerAmazon` (
470
+ `clientId` int NOT NULL,
471
+ `firstName` varchar(100) DEFAULT NULL,
472
+ `lastName` varchar(100) DEFAULT NULL,
473
+ `email` varchar(255) DEFAULT NULL,
474
+ `streetAddress` varchar(255) DEFAULT NULL,
475
+ `city` varchar(50) DEFAULT NULL,
476
+ `region` varchar(50) DEFAULT NULL,
477
+ `country` varchar(50) DEFAULT NULL,
478
+ `postalCode` varchar(50) DEFAULT NULL,
479
+ `phone` varchar(20) DEFAULT NULL,
480
+ `createdAt` datetime DEFAULT NULL,
481
+ PRIMARY KEY (`clientId`),
482
+ KEY `ixBillingCustomerAmazonEmail` (`email`)
483
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
484
+
485
+ DROP TABLE IF EXISTS `billingCustomerBraintree`;
486
+ CREATE TABLE `billingCustomerBraintree` (
487
+ `id` varchar(50) NOT NULL,
488
+ `firstName` varchar(50) DEFAULT NULL,
489
+ `lastName` varchar(50) DEFAULT NULL,
490
+ `company` varchar(100) DEFAULT NULL,
491
+ `email` varchar(255) DEFAULT NULL,
492
+ `phone` varchar(150) DEFAULT NULL,
493
+ `createdAt` datetime DEFAULT NULL,
494
+ `updatedAt` datetime DEFAULT NULL,
495
+ `churnStatus` varchar(50) DEFAULT NULL,
496
+ PRIMARY KEY (`id`),
497
+ KEY `ixBillingCustomerBraintreeEmail` (`email`)
498
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
499
+
500
+ DROP TABLE IF EXISTS `billingCustomerStripe`;
501
+ CREATE TABLE `billingCustomerStripe` (
502
+ `id` varchar(50) NOT NULL,
503
+ `name` varchar(100) DEFAULT NULL,
504
+ `email` varchar(255) DEFAULT NULL,
505
+ `phone` varchar(20) DEFAULT NULL,
506
+ `street` varchar(255) DEFAULT NULL,
507
+ `city` varchar(50) DEFAULT NULL,
508
+ `region` varchar(50) DEFAULT NULL,
509
+ `country` varchar(50) DEFAULT NULL,
510
+ `postalCode` varchar(30) DEFAULT NULL,
511
+ `createdAt` datetime DEFAULT NULL,
512
+ `updatedAt` datetime DEFAULT NULL,
513
+ `hasMigratedExpiredCard` tinyint(1) NOT NULL DEFAULT '0',
514
+ PRIMARY KEY (`id`),
515
+ KEY `ixBillingCustomerStripeEmail` (`email`)
516
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
517
+
518
+ DROP TABLE IF EXISTS `billingDeviceHistory`;
519
+ CREATE TABLE `billingDeviceHistory` (
520
+ `id` int NOT NULL AUTO_INCREMENT,
521
+ `clientId` int DEFAULT NULL,
522
+ `deviceId` int DEFAULT NULL,
523
+ `imei` varchar(15) DEFAULT NULL,
524
+ `planId` varchar(50) DEFAULT NULL,
525
+ `subscriptionId` varchar(50) DEFAULT NULL,
526
+ `platform` varchar(25) DEFAULT NULL,
527
+ `status` varchar(10) DEFAULT NULL,
528
+ `createdAt` datetime DEFAULT NULL,
529
+ PRIMARY KEY (`id`)
530
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
531
+
532
+ DROP TABLE IF EXISTS `billingDeviceTypePlan`;
533
+ CREATE TABLE `billingDeviceTypePlan` (
534
+ `id` int NOT NULL AUTO_INCREMENT,
535
+ `deviceTypeId` int NOT NULL,
536
+ `planId` varchar(50) NOT NULL,
537
+ `deviceTypeModel` varchar(50) NOT NULL,
538
+ `deviceType` varchar(50) DEFAULT NULL,
539
+ `createdAt` datetime NOT NULL,
540
+ `status` varchar(20) NOT NULL,
541
+ PRIMARY KEY (`id`),
542
+ KEY `ixBillingDeviceTypePlanDeviceTypeModel` (`deviceTypeModel`),
543
+ KEY `ixBillingDeviceTypePlanPlanId` (`planId`),
544
+ KEY `ixBillingDeviceTypePlanStatus` (`status`),
545
+ KEY `ixBillingDeviceTypePlanDeviceTypeId` (`deviceTypeId`)
546
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
547
+
548
+ DROP TABLE IF EXISTS `billingDunning`;
549
+ CREATE TABLE `billingDunning` (
550
+ `subscriptionId` varchar(100) NOT NULL,
551
+ `customerId` varchar(100) NOT NULL,
552
+ `email` varchar(255) DEFAULT NULL,
553
+ `platform` enum('shopify','braintree','acumatica','klarna','amazon','braintree_amazon','demo','stripe','stripe_amazon') NOT NULL,
554
+ `eventType` enum('campaign_started','email_bounced','campaign_recovered','campaign_lost','campaign_won') NOT NULL,
555
+ `churnBusterId` varchar(255) NOT NULL,
556
+ `captureUrl` varchar(1000) NOT NULL,
557
+ `createdAt` datetime DEFAULT NULL,
558
+ `updatedAt` datetime DEFAULT NULL,
559
+ PRIMARY KEY (`subscriptionId`),
560
+ KEY `ixBillingDunningEventType` (`subscriptionId`,`eventType`),
561
+ KEY `ixBillingDunningCustomerId` (`customerId`)
562
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
563
+
564
+ DROP TABLE IF EXISTS `billingHubspotPaymentLog`;
565
+ CREATE TABLE `billingHubspotPaymentLog` (
566
+ `id` int NOT NULL AUTO_INCREMENT,
567
+ `owner` varchar(50) DEFAULT NULL,
568
+ `amountPaid` decimal(19,4) DEFAULT NULL,
569
+ `bankOfIssuer` varchar(50) DEFAULT NULL,
570
+ `billingAddress` varchar(255) DEFAULT NULL,
571
+ `billingAddressCity` varchar(50) DEFAULT NULL,
572
+ `billingAddressCountry` varchar(3) DEFAULT NULL,
573
+ `billingAddressLine1` varchar(255) DEFAULT NULL,
574
+ `billingAddressLine2` varchar(255) DEFAULT NULL,
575
+ `billingAddressState` varchar(50) DEFAULT NULL,
576
+ `billingAddressZip` varchar(50) DEFAULT NULL,
577
+ `createdByUserId` varchar(50) DEFAULT NULL,
578
+ `currencyCode` varchar(3) DEFAULT NULL,
579
+ `customer` varchar(50) DEFAULT NULL,
580
+ `grossAmount` decimal(19,4) DEFAULT NULL,
581
+ `lastFourDigits` varchar(4) DEFAULT NULL,
582
+ `lineItemDiscountAmount` decimal(19,4) DEFAULT NULL,
583
+ `netAmount` decimal(19,4) DEFAULT NULL,
584
+ `objectCreateDateTime` datetime DEFAULT NULL,
585
+ `objectId` varchar(20) DEFAULT NULL,
586
+ `objectLastModifiedDateTime` datetime DEFAULT NULL,
587
+ `orderDiscountAmount` decimal(19,4) DEFAULT NULL,
588
+ `orderDiscountCode` varchar(50) DEFAULT NULL,
589
+ `orderDiscountPercentage` smallint NOT NULL DEFAULT '0',
590
+ `ownerAssignedDateTime` datetime DEFAULT NULL,
591
+ `paymentDateTime` datetime DEFAULT NULL,
592
+ `paymentId` varchar(20) DEFAULT NULL,
593
+ `paymentMethod` varchar(10) DEFAULT NULL,
594
+ `paymentSourceName` varchar(255) DEFAULT NULL,
595
+ `paymentType` varchar(20) DEFAULT NULL,
596
+ `processingFees` decimal(19,4) DEFAULT NULL,
597
+ `refunded` decimal(19,4) DEFAULT NULL,
598
+ `shippingAddress` varchar(255) DEFAULT NULL,
599
+ `shippingAddressCity` varchar(50) DEFAULT NULL,
600
+ `shippingAddressCountry` varchar(3) DEFAULT NULL,
601
+ `shippingAddressLine1` varchar(255) DEFAULT NULL,
602
+ `shippingAddressLine2` varchar(255) DEFAULT NULL,
603
+ `shippingAddressState` varchar(50) DEFAULT NULL,
604
+ `shippingAddressZip` varchar(50) DEFAULT NULL,
605
+ `source` varchar(20) DEFAULT NULL,
606
+ `sourceId` varchar(20) DEFAULT NULL,
607
+ `sourceUrl` varchar(255) DEFAULT NULL,
608
+ `status` varchar(10) DEFAULT NULL,
609
+ `statusUpdatedOn` datetime DEFAULT NULL,
610
+ `totalDiscountAmount` decimal(19,4) DEFAULT NULL,
611
+ `totalFees` decimal(19,4) DEFAULT NULL,
612
+ `totalTaxes` decimal(19,4) DEFAULT NULL,
613
+ `updatedByUserId` varchar(20) DEFAULT NULL,
614
+ PRIMARY KEY (`id`)
615
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
616
+
617
+ DROP TABLE IF EXISTS `billingKlarnaCustomer`;
618
+ CREATE TABLE `billingKlarnaCustomer` (
619
+ `clientId` int NOT NULL,
620
+ `firstName` varchar(100) DEFAULT NULL,
621
+ `lastName` varchar(100) DEFAULT NULL,
622
+ `billingEmail` varchar(255) DEFAULT NULL,
623
+ `shippingEmail` varchar(255) DEFAULT NULL,
624
+ `streetAddress` varchar(255) DEFAULT NULL,
625
+ `city` varchar(50) DEFAULT NULL,
626
+ `region` varchar(50) DEFAULT NULL,
627
+ `country` varchar(50) DEFAULT NULL,
628
+ `postalCode` varchar(50) DEFAULT NULL,
629
+ `phone` varchar(20) DEFAULT NULL,
630
+ `createdAt` datetime DEFAULT NULL,
631
+ PRIMARY KEY (`clientId`),
632
+ KEY `ixBillingKlarnaCustomerShippingEmail` (`shippingEmail`)
633
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
634
+
635
+ DROP TABLE IF EXISTS `billingKlarnaOrder`;
636
+ CREATE TABLE `billingKlarnaOrder` (
637
+ `imei` varchar(15) NOT NULL,
638
+ `clientId` int NOT NULL,
639
+ `orderId` varchar(255) NOT NULL,
640
+ `deviceType` varchar(50) DEFAULT NULL,
641
+ `planId` varchar(50) DEFAULT NULL,
642
+ `subscriptionStart` date DEFAULT NULL,
643
+ `subscriptionEnd` date DEFAULT NULL,
644
+ `nextBillingDate` date DEFAULT NULL,
645
+ `subscriptionValue` decimal(19,4) DEFAULT NULL,
646
+ `status` varchar(10) DEFAULT NULL,
647
+ `discounts` json DEFAULT NULL,
648
+ `addOns` json DEFAULT NULL,
649
+ `nextBillingPeriodAmount` decimal(19,4) DEFAULT NULL,
650
+ `paymentMethodToken` varchar(50) DEFAULT NULL,
651
+ `paymentType` varchar(20) DEFAULT NULL,
652
+ `createdAt` datetime DEFAULT NULL,
653
+ PRIMARY KEY (`imei`),
654
+ KEY `ixBillingKlarnaOrderCreatedAt` (`createdAt`),
655
+ KEY `ixBillingKlarnaOrderComposite` (`orderId`,`status`)
656
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
657
+
658
+ DROP TABLE IF EXISTS `billingPlanFeatures`;
659
+ CREATE TABLE `billingPlanFeatures` (
660
+ `featureId` int NOT NULL AUTO_INCREMENT,
661
+ `planId` varchar(50) NOT NULL,
662
+ `feature` text,
663
+ `status` varchar(20) NOT NULL,
664
+ PRIMARY KEY (`featureId`)
665
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
666
+
667
+ DROP TABLE IF EXISTS `billingPlans`;
668
+ CREATE TABLE `billingPlans` (
669
+ `planId` varchar(50) NOT NULL,
670
+ `targetCustomer` varchar(20) NOT NULL,
671
+ `code` varchar(50) NOT NULL,
672
+ `status` varchar(20) NOT NULL,
673
+ `platform` varchar(255) NOT NULL,
674
+ `billingFrequency` smallint NOT NULL,
675
+ `contractLength` smallint NOT NULL,
676
+ `description` varchar(255) DEFAULT NULL,
677
+ `name` varchar(255) NOT NULL,
678
+ `price` varchar(50) NOT NULL,
679
+ `startDate` datetime DEFAULT NULL,
680
+ `endDate` datetime DEFAULT NULL,
681
+ `createdAt` datetime NOT NULL,
682
+ `updatedAt` datetime NOT NULL,
683
+ PRIMARY KEY (`planId`),
684
+ KEY `ixBillingPlansStartDate_EndDate` (`startDate`,`endDate`),
685
+ KEY `ixBillingPlansTargetCustomer` (`targetCustomer`),
686
+ KEY `ixBillingPlansStatus` (`status`)
687
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
688
+
689
+ DROP TABLE IF EXISTS `billingStatusHistoryBraintree`;
690
+ CREATE TABLE `billingStatusHistoryBraintree` (
691
+ `id` int NOT NULL AUTO_INCREMENT,
692
+ `timestamp` varchar(255) DEFAULT NULL,
693
+ `status` varchar(10) DEFAULT NULL,
694
+ `balance` decimal(19,4) DEFAULT NULL,
695
+ `price` decimal(19,4) DEFAULT NULL,
696
+ `currencyIsoCode` varchar(3) DEFAULT NULL,
697
+ `planId` varchar(50) DEFAULT NULL,
698
+ `subscriptionId` varchar(25) DEFAULT NULL,
699
+ PRIMARY KEY (`id`),
700
+ KEY `ixBillingStatusHistoryBraintreeTimestamp` (`timestamp`),
701
+ KEY `ixBillingStatusHistoryBraintreeSubscriptionIdTimestamp` (`subscriptionId`,`timestamp`)
702
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
703
+
704
+ DROP TABLE IF EXISTS `billingSubscriptionAmazon`;
705
+ CREATE TABLE `billingSubscriptionAmazon` (
706
+ `imei` varchar(15) NOT NULL,
707
+ `clientId` int NOT NULL,
708
+ `subscriptionId` varchar(255) DEFAULT NULL,
709
+ `deviceType` varchar(50) DEFAULT NULL,
710
+ `asin` varchar(50) DEFAULT NULL,
711
+ `planId` varchar(50) DEFAULT NULL,
712
+ `subscriptionStart` date DEFAULT NULL,
713
+ `subscriptionEnd` date DEFAULT NULL,
714
+ `nextBillingDate` date DEFAULT NULL,
715
+ `subscriptionValue` decimal(19,4) DEFAULT NULL,
716
+ `status` varchar(10) DEFAULT NULL,
717
+ `discounts` json DEFAULT NULL,
718
+ `addOns` json DEFAULT NULL,
719
+ `nextBillingPeriodAmount` decimal(19,4) DEFAULT NULL,
720
+ `paymentMethodToken` varchar(50) DEFAULT NULL,
721
+ `scheduledSuspension` datetime DEFAULT NULL,
722
+ `paymentSkipped` tinyint(1) DEFAULT NULL,
723
+ `existsInBraintree` tinyint(1) DEFAULT NULL,
724
+ `createdAt` datetime DEFAULT NULL,
725
+ PRIMARY KEY (`imei`),
726
+ KEY `ixBillingSubscriptionAmazonCreatedAt` (`createdAt`),
727
+ KEY `ixBillingSubscriptionAmazonComposite` (`subscriptionId`,`status`)
728
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
729
+
730
+ DROP TABLE IF EXISTS `billingSubscriptionBraintree`;
731
+ CREATE TABLE `billingSubscriptionBraintree` (
732
+ `subscriptionId` varchar(50) NOT NULL,
733
+ `customerId` varchar(50) DEFAULT NULL,
734
+ `planId` varchar(50) DEFAULT NULL,
735
+ `createdAt` datetime DEFAULT NULL,
736
+ `updatedAt` datetime DEFAULT NULL,
737
+ `subscriptionStart` date DEFAULT NULL,
738
+ `subscriptionEnd` date DEFAULT NULL,
739
+ `nextBillingDate` date DEFAULT NULL,
740
+ `subscriptionValue` decimal(19,4) DEFAULT NULL,
741
+ `status` varchar(10) DEFAULT NULL,
742
+ `subscriptionPeriodMonths` tinyint DEFAULT NULL,
743
+ `paymentInstrumentType` varchar(20) DEFAULT NULL,
744
+ `paymentInstrumentDetails` json DEFAULT NULL,
745
+ `isPaused` tinyint(1) DEFAULT '0',
746
+ `discountDetails` json DEFAULT NULL,
747
+ `addons` json DEFAULT NULL,
748
+ `balance` decimal(19,4) DEFAULT NULL,
749
+ `currentBillingCycle` tinyint DEFAULT NULL,
750
+ `daysPastDue` tinyint DEFAULT NULL,
751
+ `description` varchar(255) DEFAULT NULL,
752
+ `descriptor` json DEFAULT NULL,
753
+ `failureCount` tinyint DEFAULT NULL,
754
+ `firstBillingDate` date DEFAULT NULL,
755
+ `merchantAccountId` varchar(50) DEFAULT NULL,
756
+ `nextBillingPeriodAmount` decimal(19,4) DEFAULT NULL,
757
+ `numberOfBillingCycles` tinyint DEFAULT NULL,
758
+ `paidThroughDate` date DEFAULT NULL,
759
+ `paymentMethodToken` varchar(50) DEFAULT NULL,
760
+ `statusHistory` json DEFAULT NULL,
761
+ `trialDuration` smallint DEFAULT NULL,
762
+ `trialDurationUnit` varchar(10) DEFAULT NULL,
763
+ `trialPeriod` tinyint(1) DEFAULT NULL,
764
+ PRIMARY KEY (`subscriptionId`),
765
+ KEY `ixBillingSubscriptionBraintreeCreatedAt` (`createdAt`),
766
+ KEY `ixBillingSubscriptionBraintreeComposite` (`subscriptionId`,`customerId`,`status`),
767
+ KEY `ixBillingSubscriptionBraintreeCustomerId` (`customerId`)
768
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
769
+
770
+ DROP TABLE IF EXISTS `billingSubscriptionStripe`;
771
+ CREATE TABLE `billingSubscriptionStripe` (
772
+ `subscriptionId` varchar(50) NOT NULL,
773
+ `customerId` varchar(50) NOT NULL,
774
+ `planId` varchar(50) DEFAULT NULL,
775
+ `activatedAt` datetime DEFAULT NULL,
776
+ `subscriptionStart` date DEFAULT NULL,
777
+ `subscriptionEnd` date DEFAULT NULL,
778
+ `subscriptionValue` decimal(19,4) DEFAULT NULL,
779
+ `subscriptionPeriodMonths` smallint DEFAULT NULL,
780
+ `quantity` smallint DEFAULT NULL,
781
+ `status` varchar(20) DEFAULT NULL,
782
+ `paymentType` varchar(50) DEFAULT NULL,
783
+ `paymentDetails` json DEFAULT NULL,
784
+ `discounts` json DEFAULT NULL,
785
+ `addons` json DEFAULT NULL,
786
+ `balance` decimal(19,4) DEFAULT NULL,
787
+ `paymentMethod` varchar(100) DEFAULT NULL,
788
+ `cancelAt` date DEFAULT NULL,
789
+ `canceledAt` date DEFAULT NULL,
790
+ `isPaused` tinyint(1) NOT NULL DEFAULT '0',
791
+ `resumesAt` date DEFAULT NULL,
792
+ `isTrial` tinyint(1) NOT NULL DEFAULT '0',
793
+ `trialEnd` date DEFAULT NULL,
794
+ `createdAt` datetime DEFAULT NULL,
795
+ `updatedAt` datetime DEFAULT NULL,
796
+ PRIMARY KEY (`subscriptionId`),
797
+ KEY `ixBillingSubscriptionStripeCreatedAt` (`createdAt`),
798
+ KEY `ixBillingSubscriptionStripeComposite` (`subscriptionId`,`customerId`,`status`),
799
+ KEY `ixBillingSubscriptionStripeCustomerId` (`customerId`)
800
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
801
+
802
+ DROP TABLE IF EXISTS `blacklist`;
803
+ CREATE TABLE `blacklist` (
804
+ `blacklistTypeId` tinyint NOT NULL,
805
+ `value` varchar(255) NOT NULL,
806
+ `notes` varchar(1000) DEFAULT NULL,
807
+ `createdAt` datetime DEFAULT NULL,
808
+ `createdBy` varchar(255) NOT NULL,
809
+ `modifiedAt` datetime DEFAULT NULL,
810
+ `modifiedBy` varchar(255) DEFAULT NULL,
811
+ PRIMARY KEY (`blacklistTypeId`,`value`)
812
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
813
+
814
+ DROP TABLE IF EXISTS `blacklistType`;
815
+ CREATE TABLE `blacklistType` (
816
+ `id` tinyint NOT NULL AUTO_INCREMENT,
817
+ `name` varchar(50) NOT NULL,
818
+ `description` varchar(1000) DEFAULT NULL,
819
+ PRIMARY KEY (`id`)
820
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
821
+
822
+ DROP TABLE IF EXISTS `bleMesh`;
823
+ CREATE TABLE `bleMesh` (
824
+ `id` int NOT NULL AUTO_INCREMENT,
825
+ `clientId` int NOT NULL,
826
+ `name` varchar(150) NOT NULL,
827
+ `address` varchar(500) NOT NULL,
828
+ `lat` decimal(8,6) DEFAULT NULL,
829
+ `lon` decimal(9,6) DEFAULT NULL,
830
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
831
+ `modifiedAt` datetime DEFAULT NULL,
832
+ PRIMARY KEY (`id`),
833
+ KEY `ixBLEMesh_clientId` (`clientId`)
834
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
835
+
836
+ DROP TABLE IF EXISTS `bleMeshConfiguration`;
837
+ CREATE TABLE `bleMeshConfiguration` (
838
+ `id` int NOT NULL AUTO_INCREMENT,
839
+ `imeiMain` varchar(15) NOT NULL,
840
+ `btmacMain` varchar(20) NOT NULL,
841
+ `bleMac` varchar(20) NOT NULL,
842
+ `connectionType` varchar(20) DEFAULT NULL,
843
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
844
+ `modifiedAt` datetime DEFAULT NULL,
845
+ PRIMARY KEY (`id`),
846
+ UNIQUE KEY `ixuBLEMeshConfigurationImeiMainBLEMac` (`imeiMain`,`bleMac`)
847
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
848
+
849
+ DROP TABLE IF EXISTS `boundary`;
850
+ CREATE TABLE `boundary` (
851
+ `id` int NOT NULL AUTO_INCREMENT,
852
+ `name` varchar(255) DEFAULT NULL,
853
+ `type` char(1) DEFAULT NULL,
854
+ `buffer` varchar(50) DEFAULT NULL,
855
+ `createdAt` datetime DEFAULT NULL,
856
+ `modifiedAt` datetime DEFAULT NULL,
857
+ `createdBy` varchar(50) DEFAULT NULL,
858
+ `modifiedBy` varchar(50) DEFAULT NULL,
859
+ `clientId` int NOT NULL DEFAULT '0',
860
+ `location` varchar(255) DEFAULT NULL,
861
+ `status` tinyint NOT NULL DEFAULT '1',
862
+ `radiusDisplayUnit` char(2) DEFAULT NULL,
863
+ `dataSourceTypeId` tinyint DEFAULT NULL,
864
+ `geometry` text,
865
+ `color` varchar(25) DEFAULT NULL,
866
+ `isUserCreated` tinyint(1) NOT NULL DEFAULT '1',
867
+ `area` float DEFAULT NULL,
868
+ `centerLat` decimal(8,6) DEFAULT NULL,
869
+ `centerLon` decimal(9,6) DEFAULT NULL,
870
+ PRIMARY KEY (`id`),
871
+ KEY `ixBoundaryStatus` (`status`),
872
+ KEY `ixBoundaryClientIdStatus` (`clientId`,`status`)
873
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
874
+
875
+ DROP TABLE IF EXISTS `boundaryEvent`;
876
+ CREATE TABLE `boundaryEvent` (
877
+ `id` bigint NOT NULL AUTO_INCREMENT,
878
+ `deviceId` int NOT NULL,
879
+ `boundaryId` int NOT NULL,
880
+ `inDate` datetime(3) DEFAULT NULL,
881
+ `inLat` decimal(8,6) DEFAULT NULL,
882
+ `inLon` decimal(9,6) DEFAULT NULL,
883
+ `inAddress` varchar(255) DEFAULT NULL,
884
+ `outDate` datetime(3) DEFAULT NULL,
885
+ `outLat` decimal(8,6) DEFAULT NULL,
886
+ `outLon` decimal(9,6) DEFAULT NULL,
887
+ `outAddress` varchar(255) DEFAULT NULL,
888
+ `inOutDuration` int DEFAULT NULL,
889
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
890
+ `modifiedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
891
+ `imei` varchar(15) DEFAULT NULL,
892
+ `userId` binary(16) DEFAULT NULL,
893
+ `deleted` tinyint(1) DEFAULT '0',
894
+ PRIMARY KEY (`id`),
895
+ KEY `ixBoundaryEventUserId` (`userId`),
896
+ KEY `ixBoundaryEventOutAtInAt` (`outDate`,`inDate`),
897
+ KEY `ixBoundaryEventBoundaryId` (`boundaryId`),
898
+ KEY `ixBoundaryEventDeviceId` (`deviceId`),
899
+ KEY `ixBoundaryEventDeviceId_BoundaryId_UserId_OutDate` (`deviceId`,`boundaryId`,`userId`,`outDate`),
900
+ KEY `ixBoundaryEventDeviceId_BoundaryId_UserId_InDate` (`deviceId`,`boundaryId`,`userId`,`inDate`)
901
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
902
+
903
+ DROP TABLE IF EXISTS `cellTower`;
904
+ CREATE TABLE `cellTower` (
905
+ `id` int NOT NULL,
906
+ `mcc` tinyint DEFAULT NULL,
907
+ `mnc` tinyint DEFAULT NULL,
908
+ `lac` mediumint DEFAULT NULL,
909
+ `radio` varchar(5) DEFAULT NULL,
910
+ `lat` decimal(8,6) DEFAULT NULL,
911
+ `lon` decimal(9,6) DEFAULT NULL,
912
+ `range` mediumint DEFAULT NULL,
913
+ `createdAt` datetime DEFAULT NULL,
914
+ `updatedAt` datetime DEFAULT NULL,
915
+ PRIMARY KEY (`id`)
916
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
917
+
918
+ DROP TABLE IF EXISTS `churnNotification`;
919
+ CREATE TABLE `churnNotification` (
920
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
921
+ `subscriptionId` varchar(256) DEFAULT NULL,
922
+ `customerId` varchar(255) DEFAULT NULL,
923
+ `clientId` int DEFAULT NULL,
924
+ `billingInterval` int DEFAULT NULL,
925
+ `priority` enum('low','moderate','high','critical') DEFAULT NULL,
926
+ `phase` enum('payment_failed','past_due','account_locked','prepaid_add_card','prepaid_ending_soon','add_backup_card') DEFAULT NULL,
927
+ `paymentAttempt` int DEFAULT '0',
928
+ `isPaymentFailedPushSent` tinyint(1) DEFAULT '0',
929
+ `isPastDuePushSent` tinyint(1) DEFAULT '0',
930
+ `isAccountLockedPushSent` tinyint(1) DEFAULT '0',
931
+ `isPrepaidAddCardPushSent` tinyint(1) DEFAULT '0',
932
+ `isPrepaidEndingSoonPushSent` tinyint(1) DEFAULT '0',
933
+ `isAddBackupCardPushSent` tinyint(1) DEFAULT '0',
934
+ `resolved` tinyint(1) NOT NULL DEFAULT '0',
935
+ `daysInChurn` int DEFAULT '0',
936
+ `createdAt` datetime DEFAULT NULL,
937
+ `updatedAt` datetime DEFAULT NULL,
938
+ PRIMARY KEY (`id`),
939
+ KEY `ixChurnNotificationPhaseResolved` (`phase`,`resolved`),
940
+ KEY `ixChurnNotificationClientIdResolved` (`clientId`,`resolved`),
941
+ KEY `ixChurnNotificationResolved` (`resolved`),
942
+ KEY `ixChurnNotificationCustomerId` (`customerId`),
943
+ KEY `ixChurnNotificationSubscriptionId` (`subscriptionId`)
944
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
945
+
946
+ DROP TABLE IF EXISTS `client`;
947
+ CREATE TABLE `client` (
948
+ `id` int NOT NULL AUTO_INCREMENT,
949
+ `name` varchar(255) DEFAULT NULL,
950
+ `createdAt` datetime DEFAULT NULL,
951
+ `modifiedAt` datetime DEFAULT NULL,
952
+ `uuid` binary(16) DEFAULT NULL,
953
+ `email` varchar(255) DEFAULT NULL,
954
+ `modifiedBy` varchar(50) DEFAULT NULL,
955
+ `createdBy` varchar(50) DEFAULT NULL,
956
+ `dataSourceTypeId` tinyint DEFAULT NULL,
957
+ `clientTypeId` tinyint NOT NULL DEFAULT '1',
958
+ `salesforceId` varchar(50) DEFAULT NULL,
959
+ `accumaticaId` varchar(50) DEFAULT NULL,
960
+ `expirationDate` datetime DEFAULT NULL,
961
+ `useType` varchar(25) DEFAULT NULL,
962
+ `btCustomerId` varchar(50) DEFAULT NULL,
963
+ `activationCampaign` varchar(50) DEFAULT NULL,
964
+ `organizationId` int DEFAULT NULL,
965
+ `demoAccountExpirationDate` datetime DEFAULT NULL,
966
+ `demoAccountTemplateId` smallint DEFAULT NULL,
967
+ `lastIterableSyncDate` datetime DEFAULT NULL,
968
+ `activeOrRecentlyChurned` tinyint(1) DEFAULT NULL,
969
+ `status` char(1) DEFAULT 'A',
970
+ `lockedReason` varchar(255) DEFAULT NULL,
971
+ `lockedAt` datetime DEFAULT NULL,
972
+ `lockedBy` varchar(255) DEFAULT NULL,
973
+ `notes` varchar(255) DEFAULT NULL,
974
+ PRIMARY KEY (`id`),
975
+ KEY `ixClientComposite` (`id`,`email`,`accumaticaId`,`clientTypeId`),
976
+ KEY `ixClientEmail` (`email`),
977
+ KEY `ixClientCreatedAt` (`createdAt`),
978
+ KEY `ixClientClientTypeId` (`clientTypeId`),
979
+ KEY `ixClientEmailLower` ((lower(`email`)))
980
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
981
+
982
+ DROP TABLE IF EXISTS `clientAlertConfiguration`;
983
+ CREATE TABLE `clientAlertConfiguration` (
984
+ `id` int NOT NULL AUTO_INCREMENT,
985
+ `clientId` int NOT NULL,
986
+ `alertTypeId` tinyint NOT NULL,
987
+ `name` varchar(100) NOT NULL,
988
+ `description` varchar(1000) NOT NULL,
989
+ `status` varchar(20) NOT NULL DEFAULT 'active',
990
+ `alertValue` varchar(10) DEFAULT NULL,
991
+ `alertMetadata` varchar(255) DEFAULT NULL,
992
+ `filter` json DEFAULT NULL,
993
+ `readOnly` tinyint(1) NOT NULL DEFAULT '0',
994
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
995
+ `createdBy` varchar(100) DEFAULT NULL,
996
+ `modifiedBy` varchar(100) DEFAULT NULL,
997
+ PRIMARY KEY (`id`),
998
+ KEY `ixClientAlertConfigurationClientIdCreatedAt` (`clientId`,`createdAt`),
999
+ KEY `ixClientAlertConfigurationClientIdAlertTypeId` (`clientId`,`alertTypeId`)
1000
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1001
+
1002
+ DROP TABLE IF EXISTS `clientAlertRecipient`;
1003
+ CREATE TABLE `clientAlertRecipient` (
1004
+ `id` int NOT NULL AUTO_INCREMENT,
1005
+ `clientAlertConfigurationId` int NOT NULL,
1006
+ `userId` binary(16) DEFAULT NULL,
1007
+ `roleId` tinyint DEFAULT NULL,
1008
+ `isEnabled` tinyint(1) NOT NULL DEFAULT '1',
1009
+ `smsNotification` tinyint(1) NOT NULL DEFAULT '1',
1010
+ `emailNotification` tinyint(1) NOT NULL DEFAULT '1',
1011
+ `appNotification` tinyint(1) NOT NULL DEFAULT '1',
1012
+ `pushNotification` tinyint(1) NOT NULL DEFAULT '1',
1013
+ PRIMARY KEY (`id`),
1014
+ KEY `ixClientAlertConfigurationId` (`clientAlertConfigurationId`)
1015
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1016
+
1017
+ DROP TABLE IF EXISTS `clientApiToken`;
1018
+ CREATE TABLE `clientApiToken` (
1019
+ `clientId` int NOT NULL,
1020
+ `appClientId` varchar(64) NOT NULL,
1021
+ `userId` binary(16) NOT NULL,
1022
+ `appClientName` varchar(64) NOT NULL,
1023
+ `appClientSecret` varchar(64) NOT NULL,
1024
+ `scopes` json NOT NULL,
1025
+ `createdAt` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
1026
+ `updatedAt` datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
1027
+ PRIMARY KEY (`clientId`,`appClientId`)
1028
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1029
+
1030
+ DROP TABLE IF EXISTS `clientApiTokenShareHistory`;
1031
+ CREATE TABLE `clientApiTokenShareHistory` (
1032
+ `id` int NOT NULL AUTO_INCREMENT,
1033
+ `appClientId` varchar(64) NOT NULL,
1034
+ `clientId` int NOT NULL,
1035
+ `sharedBy` varchar(100) NOT NULL,
1036
+ `sharedWith` varchar(100) NOT NULL,
1037
+ `sharedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1038
+ PRIMARY KEY (`id`),
1039
+ KEY `ix_clientId_sharedAt` (`clientId`,`sharedAt`),
1040
+ KEY `ix_appClientId_sharedAt` (`appClientId`,`sharedAt`)
1041
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1042
+
1043
+ DROP TABLE IF EXISTS `clientAppFeature`;
1044
+ CREATE TABLE `clientAppFeature` (
1045
+ `clientId` int NOT NULL,
1046
+ `appFeatureTypeId` int NOT NULL,
1047
+ `entityId` int NOT NULL,
1048
+ `statusId` int NOT NULL DEFAULT '1',
1049
+ PRIMARY KEY (`clientId`,`appFeatureTypeId`,`entityId`)
1050
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1051
+
1052
+ DROP TABLE IF EXISTS `clientConfiguration`;
1053
+ CREATE TABLE `clientConfiguration` (
1054
+ `clientId` int NOT NULL,
1055
+ `movementTripThreshold` double DEFAULT NULL,
1056
+ `stopTripThreshold` double DEFAULT NULL,
1057
+ `mapUpdateMode` tinyint DEFAULT NULL,
1058
+ `maxUsersAllowed` smallint NOT NULL DEFAULT '10',
1059
+ `ssoDomain` varchar(250) DEFAULT NULL,
1060
+ `ssoMetadata` json DEFAULT NULL,
1061
+ `assetProfileStatusLabels` json DEFAULT NULL,
1062
+ `apiKeyId` varchar(64) DEFAULT NULL,
1063
+ `assetProfileStatusLabelsEnabled` tinyint(1) NOT NULL DEFAULT '1',
1064
+ PRIMARY KEY (`clientId`),
1065
+ UNIQUE KEY `ssoDomain` (`ssoDomain`)
1066
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1067
+
1068
+ DROP TABLE IF EXISTS `clientDeviceIcon`;
1069
+ CREATE TABLE `clientDeviceIcon` (
1070
+ `id` int NOT NULL AUTO_INCREMENT,
1071
+ `clientId` int NOT NULL,
1072
+ `fileName` varchar(255) NOT NULL,
1073
+ `s3FilesPath` varchar(255) DEFAULT NULL,
1074
+ `altText` varchar(100) DEFAULT NULL,
1075
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1076
+ `modifiedAt` datetime DEFAULT NULL,
1077
+ PRIMARY KEY (`id`),
1078
+ UNIQUE KEY `ixClientDeviceIcon_clientId_fileName` (`clientId`,`fileName`)
1079
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1080
+
1081
+ DROP TABLE IF EXISTS `clientDeviceSetting`;
1082
+ CREATE TABLE `clientDeviceSetting` (
1083
+ `id` int NOT NULL AUTO_INCREMENT,
1084
+ `clientId` int NOT NULL,
1085
+ `imei` varchar(15) NOT NULL,
1086
+ `movingPingFrequency` mediumint DEFAULT NULL,
1087
+ `stoppedPingFrequency` mediumint DEFAULT NULL,
1088
+ `fixedStatus` varchar(3) DEFAULT NULL,
1089
+ `generateTrips` tinyint(1) NOT NULL DEFAULT '1',
1090
+ `stopThresholdMinutes` smallint DEFAULT NULL,
1091
+ `offlineThresholdMinutes` smallint DEFAULT NULL,
1092
+ `movementThresholdSpeed` float DEFAULT NULL,
1093
+ `externalBatteryInformation` tinyint(1) DEFAULT '0',
1094
+ `reportingMode` varchar(30) DEFAULT '',
1095
+ `starterInterruptInstalled` tinyint(1) DEFAULT '0',
1096
+ PRIMARY KEY (`id`),
1097
+ UNIQUE KEY `ixuUserDeviceSettingClientIdImei` (`clientId`,`imei`),
1098
+ KEY `ixClientDeviceSettingImei` (`imei`)
1099
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1100
+
1101
+ DROP TABLE IF EXISTS `clientIngestorConfiguration`;
1102
+ CREATE TABLE `clientIngestorConfiguration` (
1103
+ `id` int NOT NULL AUTO_INCREMENT,
1104
+ `clientId` int NOT NULL,
1105
+ `userActivationId` int NOT NULL,
1106
+ `tokenUrl` varchar(250) NOT NULL,
1107
+ `fleetUrl` varchar(250) NOT NULL,
1108
+ `requestParams` json NOT NULL,
1109
+ `isEnabled` tinyint(1) NOT NULL DEFAULT '1',
1110
+ `systemName` varchar(250) NOT NULL DEFAULT 'aemp',
1111
+ `synchroParams` json DEFAULT NULL,
1112
+ PRIMARY KEY (`id`),
1113
+ KEY `ixClientIngestorConfigurationClientId` (`clientId`)
1114
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1115
+
1116
+ DROP TABLE IF EXISTS `clientIssuesConfigurations`;
1117
+ CREATE TABLE `clientIssuesConfigurations` (
1118
+ `id` int NOT NULL AUTO_INCREMENT,
1119
+ `clientId` int NOT NULL,
1120
+ `issueTypeId` int NOT NULL,
1121
+ `dismissed` tinyint(1) DEFAULT '0',
1122
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
1123
+ `modifiedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
1124
+ PRIMARY KEY (`id`),
1125
+ UNIQUE KEY `ixuClientIssuesConfigurationClientIdIssueTypeId` (`clientId`,`issueTypeId`)
1126
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1127
+
1128
+ DROP TABLE IF EXISTS `clientStatusHistory`;
1129
+ CREATE TABLE `clientStatusHistory` (
1130
+ `id` int NOT NULL AUTO_INCREMENT,
1131
+ `clientId` int NOT NULL,
1132
+ `status` char(1) NOT NULL DEFAULT 'A',
1133
+ `modifiedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1134
+ `modifiedBy` varchar(255) DEFAULT NULL,
1135
+ `lockedReason` varchar(255) DEFAULT NULL,
1136
+ `notes` varchar(255) DEFAULT NULL,
1137
+ PRIMARY KEY (`id`),
1138
+ KEY `ix_clientId` (`clientId`)
1139
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1140
+
1141
+ DROP TABLE IF EXISTS `clientType`;
1142
+ CREATE TABLE `clientType` (
1143
+ `id` tinyint NOT NULL AUTO_INCREMENT,
1144
+ `name` varchar(50) NOT NULL,
1145
+ `description` varchar(255) NOT NULL,
1146
+ `status` varchar(10) NOT NULL DEFAULT 'active',
1147
+ PRIMARY KEY (`id`),
1148
+ KEY `ixClientTypeName` (`name`)
1149
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1150
+
1151
+ DROP TABLE IF EXISTS `country`;
1152
+ CREATE TABLE `country` (
1153
+ `id` smallint NOT NULL AUTO_INCREMENT,
1154
+ `name` varchar(50) DEFAULT NULL,
1155
+ `currencies` varchar(255) DEFAULT NULL,
1156
+ `capital` varchar(50) DEFAULT NULL,
1157
+ `region` varchar(50) DEFAULT NULL,
1158
+ `subregion` varchar(50) DEFAULT NULL,
1159
+ `languages` varchar(255) DEFAULT NULL,
1160
+ `lat` decimal(8,6) DEFAULT NULL,
1161
+ `lon` decimal(9,6) DEFAULT NULL,
1162
+ `borders` varchar(255) DEFAULT NULL,
1163
+ `area` int DEFAULT NULL,
1164
+ `internationalDirectDialing` varchar(10) DEFAULT NULL,
1165
+ `alpha2Code` varchar(2) DEFAULT NULL,
1166
+ `alpha3Code` varchar(3) DEFAULT NULL,
1167
+ PRIMARY KEY (`id`),
1168
+ KEY `ixCountryName` (`name`),
1169
+ KEY `ixCountryAlpha2Code` (`alpha2Code`)
1170
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1171
+
1172
+ DROP TABLE IF EXISTS `customReport`;
1173
+ CREATE TABLE `customReport` (
1174
+ `id` int NOT NULL AUTO_INCREMENT,
1175
+ `clientId` int NOT NULL,
1176
+ `name` varchar(50) NOT NULL,
1177
+ `description` varchar(255) DEFAULT NULL,
1178
+ `status` varchar(50) NOT NULL DEFAULT 'Active',
1179
+ `dataSourceId` tinyint NOT NULL,
1180
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1181
+ `modifiedAt` datetime DEFAULT NULL,
1182
+ `lastAccessedAt` datetime DEFAULT NULL,
1183
+ `createdBy` binary(16) DEFAULT NULL,
1184
+ `modifiedBy` binary(16) DEFAULT NULL,
1185
+ PRIMARY KEY (`id`),
1186
+ KEY `ixu_clientId` (`clientId`)
1187
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1188
+
1189
+ DROP TABLE IF EXISTS `customReportColumn`;
1190
+ CREATE TABLE `customReportColumn` (
1191
+ `id` smallint NOT NULL AUTO_INCREMENT,
1192
+ `name` varchar(50) NOT NULL,
1193
+ `key` varchar(50) NOT NULL,
1194
+ `description` varchar(255) DEFAULT NULL,
1195
+ `columnCategoryId` tinyint NOT NULL,
1196
+ `ordinalPosition` tinyint NOT NULL,
1197
+ `requiredDateFilters` tinyint(1) NOT NULL DEFAULT '0',
1198
+ `status` varchar(20) NOT NULL DEFAULT 'active',
1199
+ PRIMARY KEY (`id`),
1200
+ UNIQUE KEY `ixu_name_columnCategoryId` (`name`,`columnCategoryId`)
1201
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1202
+
1203
+ DROP TABLE IF EXISTS `customReportColumnCategory`;
1204
+ CREATE TABLE `customReportColumnCategory` (
1205
+ `id` tinyint NOT NULL AUTO_INCREMENT,
1206
+ `name` varchar(50) NOT NULL,
1207
+ `description` varchar(255) DEFAULT NULL,
1208
+ `dataSourceId` tinyint NOT NULL,
1209
+ `ordinalPosition` tinyint NOT NULL,
1210
+ `status` varchar(20) NOT NULL DEFAULT 'active',
1211
+ PRIMARY KEY (`id`),
1212
+ UNIQUE KEY `ixu_name_dataSourceId` (`name`,`dataSourceId`)
1213
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1214
+
1215
+ DROP TABLE IF EXISTS `customReportDataSource`;
1216
+ CREATE TABLE `customReportDataSource` (
1217
+ `id` tinyint NOT NULL AUTO_INCREMENT,
1218
+ `name` varchar(50) NOT NULL,
1219
+ `sourceTableName` varchar(50) NOT NULL,
1220
+ `description` varchar(255) DEFAULT NULL,
1221
+ `ordinalPosition` tinyint NOT NULL,
1222
+ `icon` varchar(50) NOT NULL,
1223
+ `status` varchar(20) NOT NULL DEFAULT 'active',
1224
+ `requiredDateFilters` tinyint(1) NOT NULL DEFAULT '0',
1225
+ PRIMARY KEY (`id`),
1226
+ UNIQUE KEY `ixu_name` (`name`)
1227
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1228
+
1229
+ DROP TABLE IF EXISTS `customReportSelectedColumn`;
1230
+ CREATE TABLE `customReportSelectedColumn` (
1231
+ `id` int NOT NULL AUTO_INCREMENT,
1232
+ `customReportId` int NOT NULL,
1233
+ `customReportColumnId` smallint NOT NULL,
1234
+ PRIMARY KEY (`id`),
1235
+ UNIQUE KEY `ixu_reportId_columnId` (`customReportId`,`customReportColumnId`)
1236
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1237
+
1238
+ DROP TABLE IF EXISTS `customSecurityRole`;
1239
+ CREATE TABLE `customSecurityRole` (
1240
+ `id` int NOT NULL AUTO_INCREMENT,
1241
+ `clientId` int NOT NULL,
1242
+ `name` varchar(255) NOT NULL,
1243
+ `permissions` json DEFAULT NULL,
1244
+ `createdAt` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
1245
+ `updatedAt` datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
1246
+ PRIMARY KEY (`id`),
1247
+ UNIQUE KEY `ixu_clientId_name` (`clientId`,`name`)
1248
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1249
+
1250
+ DROP TABLE IF EXISTS `customerAttribute`;
1251
+ CREATE TABLE `customerAttribute` (
1252
+ `clientId` int NOT NULL,
1253
+ `enterprise` tinyint(1) NOT NULL DEFAULT '0',
1254
+ `maintenanceModule` tinyint(1) NOT NULL DEFAULT '0',
1255
+ `billingMethod` enum('credit-card-hubspot','ach-hubspot','credit-card-braintree','ach-braintree','ach-wire','check','dib-sap') DEFAULT NULL,
1256
+ `customerSegment` enum('whale','bass','guppy','guppy-self-serve') DEFAULT NULL,
1257
+ PRIMARY KEY (`clientId`)
1258
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1259
+
1260
+ DROP TABLE IF EXISTS `dataExport`;
1261
+ CREATE TABLE `dataExport` (
1262
+ `id` binary(16) NOT NULL,
1263
+ `clientId` int NOT NULL,
1264
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1265
+ `completedAt` datetime DEFAULT NULL,
1266
+ `dataType` varchar(100) DEFAULT NULL,
1267
+ `status` varchar(100) DEFAULT NULL,
1268
+ `parameters` json DEFAULT NULL,
1269
+ `exportLocation` varchar(500) DEFAULT NULL,
1270
+ `downloadLink` varchar(3000) DEFAULT NULL,
1271
+ `imei` varchar(16) DEFAULT NULL,
1272
+ PRIMARY KEY (`id`)
1273
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1274
+
1275
+ DROP TABLE IF EXISTS `dataSourceType`;
1276
+ CREATE TABLE `dataSourceType` (
1277
+ `id` tinyint NOT NULL AUTO_INCREMENT,
1278
+ `name` varchar(50) NOT NULL,
1279
+ `description` varchar(255) DEFAULT NULL,
1280
+ PRIMARY KEY (`id`)
1281
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1282
+
1283
+ DROP TABLE IF EXISTS `deactivation`;
1284
+ CREATE TABLE `deactivation` (
1285
+ `id` int NOT NULL AUTO_INCREMENT,
1286
+ `imei` varchar(15) NOT NULL,
1287
+ `clientId` int NOT NULL,
1288
+ `billingSubscriptionId` varchar(50) DEFAULT NULL,
1289
+ `planId` varchar(50) DEFAULT NULL,
1290
+ `billingPlatform` varchar(100) DEFAULT NULL,
1291
+ `deactivationReason` varchar(2000) DEFAULT NULL,
1292
+ `deactivationReasonId` tinyint DEFAULT NULL,
1293
+ `createdBy` varchar(50) NOT NULL,
1294
+ `createdAt` datetime NOT NULL,
1295
+ `scheduledDate` datetime DEFAULT NULL,
1296
+ `displayOrder` tinyint DEFAULT NULL,
1297
+ PRIMARY KEY (`id`),
1298
+ KEY `ixDeactivationImei` (`imei`),
1299
+ KEY `ixDeactivationDeactivationReasonId` (`deactivationReasonId`),
1300
+ KEY `ixDeactivationBillingSubscriptionIdDeactivationReasonId` (`billingSubscriptionId`,`deactivationReasonId`),
1301
+ KEY `ixDeactivationClientId` (`clientId`)
1302
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1303
+
1304
+ DROP TABLE IF EXISTS `deactivationReason`;
1305
+ CREATE TABLE `deactivationReason` (
1306
+ `id` tinyint NOT NULL AUTO_INCREMENT,
1307
+ `text` varchar(255) NOT NULL,
1308
+ `code` varchar(50) NOT NULL,
1309
+ `customerVisible` tinyint(1) NOT NULL DEFAULT '1',
1310
+ PRIMARY KEY (`id`)
1311
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1312
+
1313
+ DROP TABLE IF EXISTS `demoAccountDeviceData`;
1314
+ CREATE TABLE `demoAccountDeviceData` (
1315
+ `imei` varchar(15) NOT NULL,
1316
+ `demoAccountTemplateDeviceId` smallint NOT NULL,
1317
+ `isBusy` tinyint(1) NOT NULL DEFAULT '0',
1318
+ `currentSiteId` int DEFAULT NULL,
1319
+ `nextAvailableAt` datetime DEFAULT NULL,
1320
+ `inMesh` tinyint(1) NOT NULL DEFAULT '0',
1321
+ PRIMARY KEY (`imei`)
1322
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1323
+
1324
+ DROP TABLE IF EXISTS `demoAccountSiteLocation`;
1325
+ CREATE TABLE `demoAccountSiteLocation` (
1326
+ `id` smallint NOT NULL AUTO_INCREMENT,
1327
+ `demoAccountTemplateId` smallint NOT NULL,
1328
+ `name` varchar(50) NOT NULL,
1329
+ `address` varchar(50) NOT NULL,
1330
+ `latitude` decimal(8,6) NOT NULL,
1331
+ `longitude` decimal(9,6) NOT NULL,
1332
+ `boundaryRadius` smallint DEFAULT NULL,
1333
+ PRIMARY KEY (`id`),
1334
+ KEY `ix_demoAccountTemplateId` (`demoAccountTemplateId`)
1335
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1336
+
1337
+ DROP TABLE IF EXISTS `demoAccountTemplate`;
1338
+ CREATE TABLE `demoAccountTemplate` (
1339
+ `id` smallint NOT NULL AUTO_INCREMENT,
1340
+ `name` varchar(50) NOT NULL,
1341
+ `randomMovementEnabled` tinyint(1) NOT NULL DEFAULT '1',
1342
+ `maxMovingDevices` smallint NOT NULL DEFAULT '2',
1343
+ PRIMARY KEY (`id`)
1344
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1345
+
1346
+ DROP TABLE IF EXISTS `demoAccountTemplateAssetProfile`;
1347
+ CREATE TABLE `demoAccountTemplateAssetProfile` (
1348
+ `id` smallint NOT NULL AUTO_INCREMENT,
1349
+ `demoAccountTemplateDeviceId` smallint NOT NULL,
1350
+ `assetName` varchar(50) NOT NULL,
1351
+ `assetProfileTypeId` smallint DEFAULT NULL,
1352
+ `make` varchar(50) DEFAULT NULL,
1353
+ `model` varchar(50) DEFAULT NULL,
1354
+ `serialNumber` varchar(50) DEFAULT NULL,
1355
+ `year` smallint DEFAULT NULL,
1356
+ PRIMARY KEY (`id`)
1357
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1358
+
1359
+ DROP TABLE IF EXISTS `demoAccountTemplateBleMesh`;
1360
+ CREATE TABLE `demoAccountTemplateBleMesh` (
1361
+ `id` smallint NOT NULL AUTO_INCREMENT,
1362
+ `demoAccountTemplateId` smallint NOT NULL,
1363
+ `name` varchar(50) NOT NULL,
1364
+ `originLocationId` smallint NOT NULL,
1365
+ `destinationLocationId` smallint NOT NULL,
1366
+ PRIMARY KEY (`id`),
1367
+ KEY `ix_demoAccountTemplateId` (`demoAccountTemplateId`)
1368
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1369
+
1370
+ DROP TABLE IF EXISTS `demoAccountTemplateDevice`;
1371
+ CREATE TABLE `demoAccountTemplateDevice` (
1372
+ `id` smallint NOT NULL AUTO_INCREMENT,
1373
+ `demoAccountTemplateId` smallint NOT NULL,
1374
+ `trackerName` varchar(50) NOT NULL,
1375
+ `trackerDescription` varchar(500) NOT NULL,
1376
+ `deviceTypeId` smallint NOT NULL,
1377
+ `demoAccountTemplateBleMeshId` smallint DEFAULT NULL,
1378
+ PRIMARY KEY (`id`)
1379
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1380
+
1381
+ DROP TABLE IF EXISTS `demoAccountTripTemplate`;
1382
+ CREATE TABLE `demoAccountTripTemplate` (
1383
+ `id` smallint NOT NULL AUTO_INCREMENT,
1384
+ `demoAccountTemplateId` smallint NOT NULL,
1385
+ `startSiteLocationId` smallint NOT NULL,
1386
+ `endSiteLocationId` smallint NOT NULL,
1387
+ `distance` int NOT NULL,
1388
+ `duration` int NOT NULL,
1389
+ PRIMARY KEY (`id`),
1390
+ KEY `ix_demoAccountTemplateId` (`demoAccountTemplateId`)
1391
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1392
+
1393
+ DROP TABLE IF EXISTS `demoAccountTripTemplatePosition`;
1394
+ CREATE TABLE `demoAccountTripTemplatePosition` (
1395
+ `id` bigint NOT NULL AUTO_INCREMENT,
1396
+ `demoAccountTripTemplateId` smallint NOT NULL,
1397
+ `latitude` decimal(8,6) NOT NULL,
1398
+ `longitude` decimal(9,6) NOT NULL,
1399
+ `speed` float NOT NULL,
1400
+ `elapsedTime` int NOT NULL,
1401
+ PRIMARY KEY (`id`),
1402
+ KEY `ix_demoAccountTripTemplateId` (`demoAccountTripTemplateId`)
1403
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1404
+
1405
+ DROP TABLE IF EXISTS `demoDeviceData`;
1406
+ CREATE TABLE `demoDeviceData` (
1407
+ `imei` varchar(15) NOT NULL,
1408
+ `associatedDeviceImei` varchar(15) DEFAULT NULL,
1409
+ `deviceAssociationStartDate` datetime DEFAULT NULL,
1410
+ `deviceAssociationEndDate` datetime DEFAULT NULL,
1411
+ `lastProcessedAt` datetime DEFAULT NULL,
1412
+ `lastProcessedSendTime` datetime DEFAULT NULL,
1413
+ PRIMARY KEY (`imei`)
1414
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1415
+
1416
+ DROP TABLE IF EXISTS `device`;
1417
+ CREATE TABLE `device` (
1418
+ `id` int NOT NULL AUTO_INCREMENT,
1419
+ `identifier` varchar(100) NOT NULL,
1420
+ `identifierKey` varchar(255) NOT NULL,
1421
+ `deviceTypeId` smallint NOT NULL,
1422
+ `imei` varchar(15) NOT NULL,
1423
+ `clientId` int NOT NULL,
1424
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1425
+ `name` varchar(255) DEFAULT NULL,
1426
+ `status` varchar(10) DEFAULT NULL,
1427
+ `iccid` varchar(25) DEFAULT NULL,
1428
+ `modifiedAt` datetime DEFAULT NULL,
1429
+ `createdBy` varchar(50) DEFAULT NULL,
1430
+ `modifiedBy` varchar(50) DEFAULT NULL,
1431
+ `forward` tinyint(1) DEFAULT NULL,
1432
+ `color` varchar(25) DEFAULT NULL,
1433
+ `icon` varchar(50) DEFAULT NULL,
1434
+ `customIconId` int DEFAULT NULL,
1435
+ `description` varchar(500) DEFAULT NULL,
1436
+ `dataSourceTypeId` tinyint DEFAULT NULL,
1437
+ `assetCategoryId` tinyint DEFAULT NULL,
1438
+ `usageRegion` varchar(25) DEFAULT NULL,
1439
+ `btmac` varchar(20) DEFAULT NULL,
1440
+ `serialNumber` varchar(36) DEFAULT NULL,
1441
+ `assignedTo` varchar(255) DEFAULT NULL,
1442
+ `assignmentMode` varchar(50) DEFAULT NULL,
1443
+ `demoAccountTemplateDeviceId` smallint DEFAULT NULL,
1444
+ `extendedAttributes` json DEFAULT NULL,
1445
+ PRIMARY KEY (`id`),
1446
+ UNIQUE KEY `ixuDeviceIdentifierKey` (`identifierKey`),
1447
+ KEY `ixDeviceSearch` (`clientId`,`status`,`imei`,`createdAt`,`deviceTypeId`),
1448
+ KEY `ixDeviceCreatedAt` (`createdAt`),
1449
+ KEY `ixDeviceClientIdImei` (`clientId`,`imei`),
1450
+ KEY `ixDeviceStatus` (`status`),
1451
+ KEY `ixDeviceImei` (`imei`),
1452
+ KEY `ixDeviceIccidImei` (`iccid`,`imei`),
1453
+ KEY `ixDeviceDeviceTypeId` (`deviceTypeId`),
1454
+ KEY `ixDeviceImeiLower` ((lower(`imei`)))
1455
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1456
+
1457
+ DROP TABLE IF EXISTS `deviceBehavior`;
1458
+ CREATE TABLE `deviceBehavior` (
1459
+ `id` smallint NOT NULL AUTO_INCREMENT,
1460
+ `deviceTypeId` smallint NOT NULL,
1461
+ `name` varchar(50) NOT NULL,
1462
+ `description` varchar(1000) NOT NULL,
1463
+ `type` varchar(25) DEFAULT NULL,
1464
+ `status` varchar(10) NOT NULL,
1465
+ `behaviorName` varchar(50) NOT NULL,
1466
+ `behaviorParams` json DEFAULT NULL,
1467
+ `extraParams` json DEFAULT NULL,
1468
+ `pendingNotes` varchar(1000) DEFAULT NULL,
1469
+ `clientId` int DEFAULT NULL,
1470
+ `imei` varchar(15) DEFAULT NULL,
1471
+ `icon` varchar(50) DEFAULT NULL,
1472
+ `confirmationNotes` varchar(1000) DEFAULT NULL,
1473
+ `ordinalPosition` tinyint NOT NULL DEFAULT '1',
1474
+ `stage` varchar(10) DEFAULT NULL,
1475
+ `additionalSettings` json DEFAULT NULL,
1476
+ `blocking` tinyint(1) DEFAULT '1',
1477
+ `displayType` varchar(25) DEFAULT NULL,
1478
+ `minWebVersion` varchar(20) DEFAULT NULL,
1479
+ `minAppVersion` varchar(20) DEFAULT NULL,
1480
+ `minProtocolVersion` varchar(255) DEFAULT NULL,
1481
+ `maxProtocolVersion` varchar(255) DEFAULT NULL,
1482
+ `isACKBehavior` tinyint(1) DEFAULT '1',
1483
+ `transmissionType` varchar(50) DEFAULT NULL,
1484
+ PRIMARY KEY (`id`),
1485
+ KEY `ixDeviceBehaviorOrdinalPosition` (`ordinalPosition`),
1486
+ KEY `ixDeviceBehaviorType` (`type`),
1487
+ KEY `ixDeviceBehaviorImei` (`imei`),
1488
+ KEY `ixDeviceBehaviorClientId` (`clientId`),
1489
+ KEY `ixDeviceBehaviorDeviceTypeId` (`deviceTypeId`)
1490
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1491
+
1492
+ DROP TABLE IF EXISTS `deviceBleMesh`;
1493
+ CREATE TABLE `deviceBleMesh` (
1494
+ `id` int NOT NULL AUTO_INCREMENT,
1495
+ `clientId` int NOT NULL,
1496
+ `deviceId` int NOT NULL,
1497
+ `bleMeshId` int NOT NULL,
1498
+ `status` varchar(100) DEFAULT NULL,
1499
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1500
+ `modifiedAt` datetime DEFAULT NULL,
1501
+ PRIMARY KEY (`id`),
1502
+ UNIQUE KEY `ixuDeviceBleMesh_deviceId` (`deviceId`),
1503
+ KEY `ixDeviceBleMesh_clientId` (`clientId`)
1504
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1505
+
1506
+ DROP TABLE IF EXISTS `deviceBleMeshUpdateTask`;
1507
+ CREATE TABLE `deviceBleMeshUpdateTask` (
1508
+ `id` binary(16) NOT NULL,
1509
+ `clientId` int NOT NULL,
1510
+ `deviceId` int NOT NULL,
1511
+ `deviceBleMeshId` int NOT NULL,
1512
+ `status` varchar(100) NOT NULL,
1513
+ `behaviorName` varchar(100) DEFAULT NULL,
1514
+ `behaviorParams` json DEFAULT NULL,
1515
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1516
+ `modifiedAt` datetime DEFAULT NULL,
1517
+ PRIMARY KEY (`id`),
1518
+ KEY `ixDeviceBleMeshUpdateTask_clientId_modifiedAt` (`clientId`,`modifiedAt`)
1519
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1520
+
1521
+ DROP TABLE IF EXISTS `deviceCameraConfiguration`;
1522
+ CREATE TABLE `deviceCameraConfiguration` (
1523
+ `clientId` int NOT NULL,
1524
+ `imei` varchar(15) NOT NULL,
1525
+ `configurationType` varchar(20) NOT NULL,
1526
+ `currentConfiguration` json DEFAULT NULL,
1527
+ `pendingConfiguration` json DEFAULT NULL,
1528
+ `updateConfigPendingCommandId` varchar(50) DEFAULT NULL,
1529
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1530
+ `modifiedAt` datetime DEFAULT NULL,
1531
+ PRIMARY KEY (`clientId`,`imei`,`configurationType`)
1532
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1533
+
1534
+ DROP TABLE IF EXISTS `deviceCameraMedia`;
1535
+ CREATE TABLE `deviceCameraMedia` (
1536
+ `clientId` int NOT NULL,
1537
+ `imei` varchar(15) NOT NULL,
1538
+ `mediaFileName` varchar(255) NOT NULL,
1539
+ `s3FilesPath` varchar(255) DEFAULT NULL,
1540
+ `thumbnailsFileName` varchar(255) DEFAULT NULL,
1541
+ `lat` decimal(8,6) DEFAULT NULL,
1542
+ `lon` decimal(9,6) DEFAULT NULL,
1543
+ `address` varchar(255) DEFAULT NULL,
1544
+ `messageId` binary(16) DEFAULT NULL,
1545
+ `eventTypeId` smallint DEFAULT NULL,
1546
+ `mediaType` enum('image','video') DEFAULT NULL COMMENT 'The type of the media: image or video',
1547
+ `cameraSource` enum('front','interior') DEFAULT NULL COMMENT 'The camera source: front or interior',
1548
+ `mediaLocation` enum('sdCard','server') NOT NULL DEFAULT 'sdCard' COMMENT 'The location of the media: sdCard or server',
1549
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1550
+ `tripId` binary(16) DEFAULT NULL,
1551
+ `requestedVideoDataId` int DEFAULT NULL,
1552
+ `requestedPictureDataId` int DEFAULT NULL,
1553
+ `deleted` tinyint(1) DEFAULT '0',
1554
+ PRIMARY KEY (`clientId`,`imei`,`mediaFileName`),
1555
+ KEY `ixDeviceCameraMedia_TripId` (`tripId`),
1556
+ KEY `ixClientIdImeiCreatedAt` (`clientId`,`imei`,`createdAt`)
1557
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1558
+
1559
+ DROP TABLE IF EXISTS `deviceCameraMediaEventType`;
1560
+ CREATE TABLE `deviceCameraMediaEventType` (
1561
+ `id` smallint NOT NULL AUTO_INCREMENT,
1562
+ `code` varchar(2) NOT NULL,
1563
+ `name` varchar(100) NOT NULL,
1564
+ `bitPosition` smallint DEFAULT NULL,
1565
+ PRIMARY KEY (`id`),
1566
+ UNIQUE KEY `ixCode` (`code`)
1567
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1568
+
1569
+ DROP TABLE IF EXISTS `deviceCameraMediaStreamingData`;
1570
+ CREATE TABLE `deviceCameraMediaStreamingData` (
1571
+ `imei` varchar(15) NOT NULL,
1572
+ `cameraSource` enum('front','interior') NOT NULL COMMENT 'The camera source: front or interior',
1573
+ `mediaLiveInputId` varchar(50) DEFAULT NULL,
1574
+ `mediaLiveChannelId` varchar(50) DEFAULT NULL,
1575
+ `rtmpServerUrl` varchar(100) DEFAULT NULL,
1576
+ `rtmpStreamKey` varchar(20) DEFAULT NULL,
1577
+ `outputUrl` varchar(255) DEFAULT NULL,
1578
+ `status` enum('requested','streaming','closed','failed','closing') DEFAULT NULL,
1579
+ `commandSequenceNumber` varchar(10) DEFAULT NULL,
1580
+ `lastRequestedAt` datetime DEFAULT NULL,
1581
+ `lastRequestedBy` binary(16) DEFAULT NULL,
1582
+ `lastViewerSeenAt` datetime DEFAULT NULL,
1583
+ PRIMARY KEY (`imei`,`cameraSource`)
1584
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1585
+
1586
+ DROP TABLE IF EXISTS `deviceCameraMediaStreamingSession`;
1587
+ CREATE TABLE `deviceCameraMediaStreamingSession` (
1588
+ `id` binary(16) NOT NULL,
1589
+ `imei` varchar(15) NOT NULL,
1590
+ `cameraSource` enum('front','interior') NOT NULL COMMENT 'The camera source: front or interior',
1591
+ `startedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1592
+ `lastHeartbeatAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1593
+ `closedAt` datetime DEFAULT NULL,
1594
+ `userId` binary(16) DEFAULT NULL,
1595
+ PRIMARY KEY (`id`)
1596
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1597
+
1598
+ DROP TABLE IF EXISTS `deviceCameraMediaSyncStatus`;
1599
+ CREATE TABLE `deviceCameraMediaSyncStatus` (
1600
+ `imei` varchar(15) NOT NULL,
1601
+ `startTime` datetime NOT NULL,
1602
+ `endTime` datetime NOT NULL,
1603
+ `status` varchar(255) NOT NULL DEFAULT 'pending',
1604
+ `retries` int NOT NULL DEFAULT '0',
1605
+ `totalFrames` int NOT NULL DEFAULT '0',
1606
+ `syncedFrames` int NOT NULL DEFAULT '0',
1607
+ `commandSequenceNumber` varchar(10) DEFAULT NULL,
1608
+ `updatedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1609
+ `syncedFrameIds` json DEFAULT NULL,
1610
+ `filesInCard` tinyint(1) DEFAULT '1',
1611
+ `deleteCmdSequenceNumber` varchar(10) DEFAULT NULL,
1612
+ PRIMARY KEY (`imei`,`startTime`,`endTime`),
1613
+ KEY `ixDeviceCameraMediaSyncStatus_imei_status_updatedAt` (`imei`,`status`,`updatedAt`)
1614
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1615
+
1616
+ DROP TABLE IF EXISTS `deviceCameraRequestedPictureData`;
1617
+ CREATE TABLE `deviceCameraRequestedPictureData` (
1618
+ `id` int NOT NULL AUTO_INCREMENT,
1619
+ `commandSequenceNumber` varchar(10) NOT NULL,
1620
+ `clientId` int NOT NULL,
1621
+ `imei` varchar(15) NOT NULL,
1622
+ `cameraSource` int NOT NULL,
1623
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1624
+ `status` varchar(255) NOT NULL DEFAULT 'pending',
1625
+ `receivedFileName` varchar(255) DEFAULT NULL,
1626
+ `receivedFileDate` datetime DEFAULT NULL,
1627
+ `requestedBy` binary(16) NOT NULL,
1628
+ PRIMARY KEY (`id`),
1629
+ KEY `ix_clientId_imei_createdAt` (`clientId`,`imei`,`createdAt`)
1630
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1631
+
1632
+ DROP TABLE IF EXISTS `deviceCameraRequestedVideoData`;
1633
+ CREATE TABLE `deviceCameraRequestedVideoData` (
1634
+ `id` int NOT NULL AUTO_INCREMENT,
1635
+ `commandSequenceNumber` varchar(10) NOT NULL,
1636
+ `clientId` int NOT NULL,
1637
+ `imei` varchar(15) NOT NULL,
1638
+ `startTime` datetime NOT NULL,
1639
+ `duration` int NOT NULL,
1640
+ `cameraSource` int NOT NULL,
1641
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1642
+ `totalFilesCount` int DEFAULT '0',
1643
+ `receivedFilesCount` int DEFAULT '0',
1644
+ `receivedFiles` json DEFAULT NULL,
1645
+ `status` varchar(255) NOT NULL DEFAULT 'pending',
1646
+ `resultFileName` varchar(255) DEFAULT NULL,
1647
+ `requestedBy` binary(16) NOT NULL,
1648
+ PRIMARY KEY (`id`),
1649
+ KEY `ix_clientId_imei_createdAt` (`clientId`,`imei`,`createdAt`)
1650
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1651
+
1652
+ DROP TABLE IF EXISTS `deviceChangesHistory`;
1653
+ CREATE TABLE `deviceChangesHistory` (
1654
+ `id` int NOT NULL AUTO_INCREMENT,
1655
+ `clientId` int NOT NULL,
1656
+ `imei` varchar(15) NOT NULL,
1657
+ `assignedTo` varchar(255) NOT NULL,
1658
+ `startDate` datetime DEFAULT CURRENT_TIMESTAMP,
1659
+ `endDate` datetime DEFAULT NULL,
1660
+ PRIMARY KEY (`id`),
1661
+ KEY `ixuDeviceChangesHistoryClientIdImei` (`clientId`,`imei`)
1662
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1663
+
1664
+ DROP TABLE IF EXISTS `deviceCustomConfiguration`;
1665
+ CREATE TABLE `deviceCustomConfiguration` (
1666
+ `id` mediumint NOT NULL AUTO_INCREMENT,
1667
+ `clientId` int DEFAULT NULL,
1668
+ `deviceTypeId` smallint DEFAULT NULL,
1669
+ `imei` varchar(15) DEFAULT NULL,
1670
+ `configFileUrl` varchar(1000) DEFAULT NULL,
1671
+ `skipActivationDefaults` tinyint(1) NOT NULL DEFAULT '0',
1672
+ `createdAt` datetime DEFAULT NULL,
1673
+ `po` varchar(25) DEFAULT NULL,
1674
+ PRIMARY KEY (`id`),
1675
+ KEY `ixDeviceCustomConfigurationsClientId` (`clientId`)
1676
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1677
+
1678
+ DROP TABLE IF EXISTS `deviceEventsTriggerConfiguration`;
1679
+ CREATE TABLE `deviceEventsTriggerConfiguration` (
1680
+ `clientId` int NOT NULL,
1681
+ `imei` varchar(15) NOT NULL,
1682
+ `eventBehaviorType` enum('takePicture','takeVideo','uploadPicture','uploadVideo') NOT NULL,
1683
+ `eventsConfiguration` json DEFAULT NULL,
1684
+ `pendingEventsConfiguration` json DEFAULT NULL,
1685
+ `updateConfigPendingCommandId` varchar(50) DEFAULT NULL,
1686
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1687
+ `modifiedAt` datetime DEFAULT NULL,
1688
+ `extraParams` json DEFAULT NULL,
1689
+ `pendingExtraParams` json DEFAULT NULL,
1690
+ PRIMARY KEY (`clientId`,`imei`,`eventBehaviorType`)
1691
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1692
+
1693
+ DROP TABLE IF EXISTS `deviceHistory`;
1694
+ CREATE TABLE `deviceHistory` (
1695
+ `id` bigint NOT NULL AUTO_INCREMENT,
1696
+ `clientId` int DEFAULT NULL,
1697
+ `imei` varchar(15) NOT NULL,
1698
+ `trackerName` varchar(255) DEFAULT NULL,
1699
+ `status` varchar(10) DEFAULT NULL,
1700
+ `createAt` datetime DEFAULT NULL,
1701
+ PRIMARY KEY (`id`)
1702
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1703
+
1704
+ DROP TABLE IF EXISTS `deviceModelListener`;
1705
+ CREATE TABLE `deviceModelListener` (
1706
+ `id` smallint NOT NULL AUTO_INCREMENT,
1707
+ `url` varchar(1000) DEFAULT NULL,
1708
+ `portNumber` smallint DEFAULT NULL,
1709
+ `protocol` varchar(5) DEFAULT NULL,
1710
+ `deviceTypeId` smallint DEFAULT NULL,
1711
+ `status` varchar(25) DEFAULT NULL,
1712
+ PRIMARY KEY (`id`)
1713
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1714
+
1715
+ DROP TABLE IF EXISTS `devicePairing`;
1716
+ CREATE TABLE `devicePairing` (
1717
+ `id` int NOT NULL AUTO_INCREMENT,
1718
+ `imeiMain` varchar(15) NOT NULL,
1719
+ `btmacMain` varchar(20) NOT NULL,
1720
+ `imeiSecondary` varchar(15) NOT NULL,
1721
+ `btmacSecondary` varchar(20) NOT NULL,
1722
+ `pairingMode` varchar(20) DEFAULT NULL,
1723
+ `connectionType` varchar(20) DEFAULT NULL,
1724
+ `mainDeviceStatus` varchar(1000) DEFAULT NULL,
1725
+ `secondaryDeviceStatus` varchar(1000) DEFAULT NULL,
1726
+ `notes` varchar(1000) DEFAULT NULL,
1727
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
1728
+ `modifiedAt` datetime DEFAULT NULL,
1729
+ PRIMARY KEY (`id`),
1730
+ UNIQUE KEY `ixuDevicePairingImeiMainImeiSecondary` (`imeiMain`,`imeiSecondary`),
1731
+ UNIQUE KEY `ixuDevicePairingImeiMain` (`imeiMain`),
1732
+ UNIQUE KEY `ixuDevicePairingImeiSecondary` (`imeiSecondary`)
1733
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1734
+
1735
+ DROP TABLE IF EXISTS `devicePromotion`;
1736
+ CREATE TABLE `devicePromotion` (
1737
+ `imei` varchar(15) NOT NULL,
1738
+ `promotionId` int NOT NULL,
1739
+ PRIMARY KEY (`imei`,`promotionId`)
1740
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1741
+
1742
+ DROP TABLE IF EXISTS `deviceReplacement`;
1743
+ CREATE TABLE `deviceReplacement` (
1744
+ `id` int NOT NULL AUTO_INCREMENT,
1745
+ `imeiOld` varchar(15) NOT NULL,
1746
+ `iccidOld` varchar(25) NOT NULL,
1747
+ `imeiNew` varchar(15) NOT NULL,
1748
+ `iccidNew` varchar(25) NOT NULL,
1749
+ `userId` binary(16) NOT NULL,
1750
+ `clientId` int NOT NULL,
1751
+ `createAt` datetime NOT NULL,
1752
+ PRIMARY KEY (`id`),
1753
+ KEY `ixDeviceReplacementImeiOld` (`imeiOld`),
1754
+ KEY `ixDeviceReplacementClientId` (`clientId`)
1755
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1756
+
1757
+ DROP TABLE IF EXISTS `deviceStatus`;
1758
+ CREATE TABLE `deviceStatus` (
1759
+ `imei` varchar(15) NOT NULL,
1760
+ `clientId` int NOT NULL,
1761
+ `created` datetime NOT NULL,
1762
+ `sendTime` datetime NOT NULL,
1763
+ `data` json DEFAULT NULL,
1764
+ PRIMARY KEY (`imei`),
1765
+ KEY `ixDeviceStatusCreated` (`created`),
1766
+ KEY `ixDeviceStatusSendTime` (`sendTime`),
1767
+ KEY `ixDeviceStatusClientId_SendTime` (`clientId`,`sendTime`)
1768
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1769
+
1770
+ DROP TABLE IF EXISTS `deviceTask`;
1771
+ CREATE TABLE `deviceTask` (
1772
+ `taskScheduleId` int NOT NULL,
1773
+ `imei` varchar(15) NOT NULL,
1774
+ `clientId` int NOT NULL,
1775
+ PRIMARY KEY (`taskScheduleId`,`imei`),
1776
+ KEY `ixDeviceTask_Imei` (`imei`),
1777
+ KEY `ixDeviceTask_ClientId` (`clientId`)
1778
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1779
+
1780
+ DROP TABLE IF EXISTS `deviceType`;
1781
+ CREATE TABLE `deviceType` (
1782
+ `id` smallint NOT NULL AUTO_INCREMENT,
1783
+ `brand` varchar(50) NOT NULL,
1784
+ `model` varchar(50) NOT NULL,
1785
+ `modelFamily` varchar(50) NOT NULL,
1786
+ `description` varchar(500) DEFAULT NULL,
1787
+ `tags` varchar(255) DEFAULT NULL,
1788
+ `url` varchar(1000) DEFAULT NULL,
1789
+ `name` varchar(50) DEFAULT NULL,
1790
+ `pictureUrl` varchar(1000) DEFAULT NULL,
1791
+ `userManualUrl` varchar(1000) DEFAULT NULL,
1792
+ `notes` varchar(2000) DEFAULT NULL,
1793
+ `supported` tinyint(1) DEFAULT NULL,
1794
+ `activatable` tinyint(1) DEFAULT NULL,
1795
+ `selfActivatable` tinyint(1) DEFAULT NULL,
1796
+ `port` smallint DEFAULT NULL,
1797
+ `protocolMatch` varchar(5) DEFAULT NULL,
1798
+ `stage` varchar(10) DEFAULT NULL,
1799
+ `identifierType` varchar(20) NOT NULL,
1800
+ `landingPage` varchar(1000) DEFAULT NULL,
1801
+ `troubleshooting` varchar(1000) DEFAULT NULL,
1802
+ `protocol` varchar(50) DEFAULT NULL,
1803
+ `readOnly` tinyint(1) DEFAULT NULL,
1804
+ `customerFacingModel` varchar(50) DEFAULT NULL,
1805
+ `customerFacingName` varchar(50) DEFAULT NULL,
1806
+ PRIMARY KEY (`id`)
1807
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1808
+
1809
+ DROP TABLE IF EXISTS `deviceTypeFeature`;
1810
+ CREATE TABLE `deviceTypeFeature` (
1811
+ `deviceTypeId` smallint NOT NULL,
1812
+ `featureKey` varchar(50) NOT NULL,
1813
+ `value` varchar(255) DEFAULT NULL,
1814
+ PRIMARY KEY (`deviceTypeId`,`featureKey`),
1815
+ KEY `ixDeviceTypeFeatureFeatureKey` (`featureKey`)
1816
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1817
+
1818
+ DROP TABLE IF EXISTS `deviceTypeFirmware`;
1819
+ CREATE TABLE `deviceTypeFirmware` (
1820
+ `id` mediumint NOT NULL AUTO_INCREMENT,
1821
+ `deviceTypeId` smallint NOT NULL,
1822
+ `sourceFirmwareVersion` varchar(25) DEFAULT NULL,
1823
+ `firmwareVersion` varchar(25) DEFAULT NULL,
1824
+ `firmwareCode` varchar(50) DEFAULT NULL,
1825
+ `firmwareUrl` varchar(1000) DEFAULT NULL,
1826
+ `releaseDate` datetime DEFAULT NULL,
1827
+ `description` varchar(1000) DEFAULT NULL,
1828
+ `enabled` tinyint(1) NOT NULL DEFAULT '0',
1829
+ `upgradeType` varchar(25) DEFAULT NULL,
1830
+ `postUpgradeConfig` varchar(1000) DEFAULT NULL,
1831
+ `stage` varchar(25) DEFAULT NULL,
1832
+ `parentId` mediumint DEFAULT NULL,
1833
+ `maxDeployPercentage` smallint DEFAULT NULL,
1834
+ `qmsRate` smallint DEFAULT NULL,
1835
+ `pendingTimeout` smallint DEFAULT NULL,
1836
+ `forceSMS` tinyint(1) NOT NULL DEFAULT '0',
1837
+ `MCUFirmwareVersion` varchar(25) DEFAULT NULL,
1838
+ `sourceMCUFirmwareVersion` varchar(25) DEFAULT NULL,
1839
+ `sourceBTFirmwareVersion` varchar(25) DEFAULT NULL,
1840
+ `BTFirmwareVersion` varchar(25) DEFAULT NULL,
1841
+ `sourceModemFirmwareVersion` varchar(25) DEFAULT NULL,
1842
+ `modemFirmwareVersion` varchar(25) DEFAULT NULL,
1843
+ `sourcePlatformFirmwareVersion` varchar(25) DEFAULT NULL,
1844
+ `platformFirmwareVersion` varchar(25) DEFAULT NULL,
1845
+ PRIMARY KEY (`id`),
1846
+ KEY `ixDeviceTypeFirmwareDeviceTypeId` (`deviceTypeId`)
1847
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1848
+
1849
+ DROP TABLE IF EXISTS `deviceTypePromotion`;
1850
+ CREATE TABLE `deviceTypePromotion` (
1851
+ `deviceTypeId` smallint NOT NULL,
1852
+ `promotionId` int NOT NULL,
1853
+ PRIMARY KEY (`deviceTypeId`,`promotionId`)
1854
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1855
+
1856
+ DROP TABLE IF EXISTS `emailDomain`;
1857
+ CREATE TABLE `emailDomain` (
1858
+ `id` mediumint NOT NULL AUTO_INCREMENT,
1859
+ `name` varchar(100) DEFAULT NULL,
1860
+ `isBusiness` tinyint(1) DEFAULT '0',
1861
+ PRIMARY KEY (`id`)
1862
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1863
+
1864
+ DROP TABLE IF EXISTS `entityTag`;
1865
+ CREATE TABLE `entityTag` (
1866
+ `id` int NOT NULL AUTO_INCREMENT,
1867
+ `tagId` int NOT NULL,
1868
+ `clientId` int NOT NULL,
1869
+ `entityType` enum('Device','Boundary','User','UserInvitation','ClientAlertConfiguration','LiveLink') NOT NULL,
1870
+ `entityId` int NOT NULL,
1871
+ `metadata` json DEFAULT NULL,
1872
+ `createdBy` varchar(50) NOT NULL,
1873
+ `createdAt` datetime NOT NULL,
1874
+ `modifiedBy` varchar(50) DEFAULT NULL,
1875
+ `modifiedAt` datetime DEFAULT NULL,
1876
+ `userId` binary(16) DEFAULT NULL,
1877
+ `imei` varchar(15) DEFAULT NULL,
1878
+ `isSecurityGroup` tinyint(1) NOT NULL DEFAULT '0',
1879
+ PRIMARY KEY (`id`),
1880
+ UNIQUE KEY `ixEntityTagClientIdEntityIdTagIdEntityType` (`clientId`,`entityId`,`tagId`,`entityType`),
1881
+ KEY `ixEntityTagEntityIdEntityTypeIsSecurityGroupTagId` (`entityId`,`entityType`,`isSecurityGroup`,`tagId`),
1882
+ KEY `ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId` (`clientId`,`userId`,`entityType`,`isSecurityGroup`,`tagId`),
1883
+ KEY `ixEntityTagUserIdEntityTypeIsSecurityGroupTagId` (`userId`,`entityType`,`isSecurityGroup`,`tagId`),
1884
+ KEY `ixEntityTagUserIdIsSecurityGroupTagId` (`userId`,`isSecurityGroup`,`tagId`),
1885
+ KEY `ixEntityTagImeiIsSecurityGroupTagId` (`imei`,`isSecurityGroup`,`tagId`),
1886
+ KEY `ixEntityTagTagId` (`tagId`),
1887
+ KEY `ixEntityTagEntityType` (`entityType`)
1888
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1889
+
1890
+ DROP TABLE IF EXISTS `entityType`;
1891
+ CREATE TABLE `entityType` (
1892
+ `id` tinyint NOT NULL AUTO_INCREMENT,
1893
+ `name` varchar(50) NOT NULL,
1894
+ `description` varchar(1000) NOT NULL,
1895
+ PRIMARY KEY (`id`)
1896
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1897
+
1898
+ DROP TABLE IF EXISTS `feature`;
1899
+ CREATE TABLE `feature` (
1900
+ `key` varchar(50) NOT NULL,
1901
+ `name` varchar(50) NOT NULL,
1902
+ `description` varchar(255) DEFAULT NULL,
1903
+ `tags` varchar(500) DEFAULT NULL,
1904
+ PRIMARY KEY (`key`)
1905
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1906
+
1907
+ DROP TABLE IF EXISTS `firmwareAutoUpgradeBlacklist`;
1908
+ CREATE TABLE `firmwareAutoUpgradeBlacklist` (
1909
+ `id` mediumint NOT NULL AUTO_INCREMENT,
1910
+ `clientId` int DEFAULT NULL,
1911
+ `deviceTypeId` int DEFAULT NULL,
1912
+ `imei` varchar(15) DEFAULT NULL,
1913
+ PRIMARY KEY (`id`),
1914
+ UNIQUE KEY `ixuFirmwareAutoUpgradeBlacklistClientIdDeviceTypeId` (`clientId`,`deviceTypeId`)
1915
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1916
+
1917
+ DROP TABLE IF EXISTS `firmwareUpgradeTask`;
1918
+ CREATE TABLE `firmwareUpgradeTask` (
1919
+ `id` binary(16) NOT NULL,
1920
+ `deviceTypeFirmwareId` mediumint NOT NULL,
1921
+ `clientId` int NOT NULL,
1922
+ `imei` varchar(15) NOT NULL,
1923
+ `status` varchar(40) NOT NULL,
1924
+ `behaviorName` varchar(25) DEFAULT NULL,
1925
+ `behaviorParams` json DEFAULT NULL,
1926
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
1927
+ `modifiedAt` datetime DEFAULT NULL,
1928
+ `preConfig` text,
1929
+ `postConfig` text,
1930
+ `commandsTaskId` varchar(50) DEFAULT NULL,
1931
+ `postUpgradeCompleted` tinyint(1) DEFAULT '0',
1932
+ `fwCompletedOn` datetime DEFAULT NULL,
1933
+ PRIMARY KEY (`id`),
1934
+ KEY `ix_deviceTypeFirmwareId_status` (`deviceTypeFirmwareId`,`status`),
1935
+ KEY `ixFirmwareUpgradeTaskStatusEtc` (`status`,`postUpgradeCompleted`,`deviceTypeFirmwareId`,`modifiedAt`),
1936
+ KEY `ixFirmwareUpgradeTaskImeiModifiedAt` (`imei`,`modifiedAt`),
1937
+ KEY `ixFirmwareUpgradeTaskDeviceTypeFirmwareIdModifiedAt` (`deviceTypeFirmwareId`,`modifiedAt`)
1938
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1939
+
1940
+ DROP TABLE IF EXISTS `historicalBillingPlan`;
1941
+ CREATE TABLE `historicalBillingPlan` (
1942
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
1943
+ `planId` varchar(100) NOT NULL,
1944
+ `name` varchar(100) NOT NULL,
1945
+ `description` varchar(256) DEFAULT NULL,
1946
+ `consumer` varchar(30) NOT NULL,
1947
+ `modelFamily` varchar(30) NOT NULL,
1948
+ `model` varchar(30) DEFAULT NULL,
1949
+ `planCode` varchar(100) NOT NULL,
1950
+ `price` decimal(19,4) NOT NULL,
1951
+ `totalPrice` decimal(19,4) NOT NULL,
1952
+ `billingInterval` smallint NOT NULL,
1953
+ `annual` tinyint(1) NOT NULL,
1954
+ `prepaid` tinyint(1) NOT NULL,
1955
+ `legacy` tinyint(1) NOT NULL,
1956
+ `test` tinyint(1) NOT NULL,
1957
+ `validFrom` date DEFAULT NULL,
1958
+ `validUntil` date DEFAULT NULL,
1959
+ `createdAt` datetime NOT NULL,
1960
+ `new` tinyint(1) NOT NULL,
1961
+ `enabled` tinyint(1) NOT NULL,
1962
+ PRIMARY KEY (`id`),
1963
+ UNIQUE KEY `ixuHistoricalBillingPlanPlanIdConsumerModelValidFromValidUntil` (`planId`,`consumer`,`model`,`validFrom`,`validUntil`),
1964
+ KEY `ixHistoricalBillingPlanModelConsumerAnnualPlanCode` (`model`,`consumer`,`annual`,`planCode`)
1965
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1966
+
1967
+ DROP TABLE IF EXISTS `iccidStatus`;
1968
+ CREATE TABLE `iccidStatus` (
1969
+ `iccid` varchar(25) NOT NULL,
1970
+ `status` varchar(100) DEFAULT NULL,
1971
+ `processing` tinyint(1) DEFAULT NULL,
1972
+ `carrierFound` int DEFAULT NULL,
1973
+ `modifiedAt` datetime DEFAULT NULL,
1974
+ PRIMARY KEY (`iccid`),
1975
+ KEY `ixIccidStatusModifiedAt` (`modifiedAt`),
1976
+ KEY `ixIccidStatusProcessing` (`processing`)
1977
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1978
+
1979
+ DROP TABLE IF EXISTS `imeiIccidCarrier`;
1980
+ CREATE TABLE `imeiIccidCarrier` (
1981
+ `id` int NOT NULL AUTO_INCREMENT,
1982
+ `imei` varchar(15) DEFAULT NULL,
1983
+ `iccid` varchar(25) DEFAULT NULL,
1984
+ `carrier` tinyint DEFAULT NULL,
1985
+ `phone` varchar(25) DEFAULT NULL,
1986
+ `deviceTypeId` smallint DEFAULT NULL,
1987
+ `serviceProviderProductId` tinyint DEFAULT NULL,
1988
+ `isValid` tinyint(1) NOT NULL DEFAULT '1',
1989
+ `model` varchar(50) DEFAULT NULL,
1990
+ `realModel` varchar(50) DEFAULT NULL,
1991
+ `po` varchar(25) DEFAULT NULL,
1992
+ `outOfInventory` tinyint(1) NOT NULL DEFAULT '0',
1993
+ `apn` varchar(50) DEFAULT NULL,
1994
+ `createdAt` datetime DEFAULT NULL,
1995
+ `modifiedAt` datetime DEFAULT NULL,
1996
+ `itsEsim` tinyint(1) DEFAULT '0',
1997
+ `btmac` varchar(20) DEFAULT NULL,
1998
+ PRIMARY KEY (`id`),
1999
+ KEY `ixImeiIccidCarrierProductId` (`serviceProviderProductId`),
2000
+ KEY `ixImeiIccidCarrierModifiedAt` (`modifiedAt`),
2001
+ KEY `ixImeiIccidCarrierImei` (`imei`),
2002
+ KEY `ixImeiIccidCarrierIccid` (`iccid`),
2003
+ KEY `ixImeiIccidCarrierDeviceTypeId` (`deviceTypeId`),
2004
+ KEY `ixImeiIccidCarrierCarrier` (`carrier`)
2005
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2006
+
2007
+ DROP TABLE IF EXISTS `imeiIccidHistory`;
2008
+ CREATE TABLE `imeiIccidHistory` (
2009
+ `id` int NOT NULL AUTO_INCREMENT,
2010
+ `iccid` varchar(25) DEFAULT NULL,
2011
+ `imei` varchar(15) NOT NULL,
2012
+ `carrier` tinyint NOT NULL,
2013
+ `lastUpdatedAt` datetime NOT NULL,
2014
+ PRIMARY KEY (`id`),
2015
+ KEY `ixImeiIccidHistoryImei` (`imei`),
2016
+ KEY `ixImeiIccidHistoryIccid` (`iccid`)
2017
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2018
+
2019
+ DROP TABLE IF EXISTS `imeiIccidImport`;
2020
+ CREATE TABLE `imeiIccidImport` (
2021
+ `imei` varchar(15) NOT NULL,
2022
+ `iccid` varchar(25) NOT NULL,
2023
+ `btmac` varchar(20) DEFAULT NULL,
2024
+ PRIMARY KEY (`imei`,`iccid`)
2025
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2026
+
2027
+ DROP TABLE IF EXISTS `industry`;
2028
+ CREATE TABLE `industry` (
2029
+ `id` smallint NOT NULL AUTO_INCREMENT,
2030
+ `industry` varchar(100) NOT NULL,
2031
+ `mainIndustry` varchar(100) NOT NULL,
2032
+ `group` varchar(100) NOT NULL,
2033
+ `sector` varchar(100) NOT NULL,
2034
+ `displayName` varchar(100) DEFAULT NULL,
2035
+ PRIMARY KEY (`id`)
2036
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2037
+
2038
+ DROP TABLE IF EXISTS `issueTypes`;
2039
+ CREATE TABLE `issueTypes` (
2040
+ `id` smallint NOT NULL AUTO_INCREMENT,
2041
+ `name` varchar(50) NOT NULL,
2042
+ `title` varchar(255) DEFAULT NULL,
2043
+ `description` varchar(2000) DEFAULT NULL,
2044
+ `resolution` varchar(2000) DEFAULT NULL,
2045
+ `icon` varchar(50) DEFAULT NULL,
2046
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2047
+ PRIMARY KEY (`id`)
2048
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2049
+
2050
+ DROP TABLE IF EXISTS `issues`;
2051
+ CREATE TABLE `issues` (
2052
+ `id` bigint NOT NULL AUTO_INCREMENT,
2053
+ `issueTypeId` smallint NOT NULL,
2054
+ `value` varchar(5000) DEFAULT NULL,
2055
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2056
+ `modifiedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2057
+ `modifiedBy` binary(16) DEFAULT NULL,
2058
+ `sendTime` datetime(3) DEFAULT NULL,
2059
+ `messageId` binary(16) DEFAULT NULL,
2060
+ `lat` decimal(8,6) DEFAULT NULL,
2061
+ `lon` decimal(9,6) DEFAULT NULL,
2062
+ `address` varchar(255) DEFAULT NULL,
2063
+ `imei` varchar(15) NOT NULL,
2064
+ `clientId` int NOT NULL,
2065
+ `status` varchar(50) NOT NULL DEFAULT 'active',
2066
+ `snoozedUntil` datetime(3) DEFAULT NULL,
2067
+ `resolvedAt` datetime(3) DEFAULT NULL,
2068
+ `resolvedConfirmationAt` datetime(3) DEFAULT NULL,
2069
+ `resolvedMessageId` binary(16) DEFAULT NULL,
2070
+ `deleted` tinyint(1) DEFAULT '0',
2071
+ PRIMARY KEY (`id`),
2072
+ KEY `ixIssueStatus_SnoozedUntil_ModifiedAt` (`status`,`snoozedUntil`,`modifiedAt`),
2073
+ KEY `ixIssueClientId_Status_IssueTypeId_CreatedAt` (`clientId`,`status`,`issueTypeId`,`createdAt`),
2074
+ KEY `ixIssueClientId_Imei_Status_CreatedAt` (`clientId`,`imei`,`status`,`createdAt`)
2075
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2076
+
2077
+ DROP TABLE IF EXISTS `latestPosition`;
2078
+ CREATE TABLE `latestPosition` (
2079
+ `imei` varchar(15) NOT NULL,
2080
+ `positionId` bigint NOT NULL,
2081
+ `lat` decimal(8,6) DEFAULT NULL,
2082
+ `lon` decimal(9,6) DEFAULT NULL,
2083
+ `actualDate` datetime(3) NOT NULL,
2084
+ `speed` float DEFAULT NULL,
2085
+ `odometer` double DEFAULT NULL,
2086
+ `createdAt` datetime(3) NOT NULL,
2087
+ `messageId` binary(16) NOT NULL,
2088
+ `batteryPercentage` smallint DEFAULT NULL,
2089
+ `clientId` int DEFAULT NULL,
2090
+ `address` varchar(255) DEFAULT NULL,
2091
+ `sendTime` datetime(3) DEFAULT NULL,
2092
+ `gpsUtcTime` datetime(3) DEFAULT NULL,
2093
+ `externalBatteryPercentage` smallint DEFAULT NULL,
2094
+ `externalPowerVoltage` float DEFAULT NULL,
2095
+ `azimuth` smallint DEFAULT NULL,
2096
+ `motionDetected` tinyint(1) DEFAULT NULL,
2097
+ PRIMARY KEY (`imei`),
2098
+ UNIQUE KEY `ixuLatestPositionMessageId` (`messageId`),
2099
+ KEY `ixLatestPositionId` (`positionId`),
2100
+ KEY `ixLatestPositionClientId` (`clientId`),
2101
+ KEY `ixLatestPositionActualDate` (`actualDate`)
2102
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2103
+
2104
+ DROP TABLE IF EXISTS `latestUserAppInfo`;
2105
+ CREATE TABLE `latestUserAppInfo` (
2106
+ `id` int NOT NULL AUTO_INCREMENT,
2107
+ `userId` binary(16) NOT NULL,
2108
+ `deviceOs` varchar(15) NOT NULL,
2109
+ `appVersion` varchar(25) NOT NULL,
2110
+ `createdAt` datetime NOT NULL,
2111
+ PRIMARY KEY (`id`),
2112
+ UNIQUE KEY `ixLatestUserAppInfoUserId` (`userId`)
2113
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2114
+
2115
+ DROP TABLE IF EXISTS `liveLink`;
2116
+ CREATE TABLE `liveLink` (
2117
+ `id` binary(16) NOT NULL,
2118
+ `name` varchar(100) NOT NULL,
2119
+ `clientId` int NOT NULL,
2120
+ `status` varchar(10) NOT NULL DEFAULT 'active',
2121
+ `startDate` datetime DEFAULT NULL,
2122
+ `endDate` datetime DEFAULT NULL,
2123
+ `deviceAccess` varchar(255) NOT NULL,
2124
+ `devices` json DEFAULT NULL,
2125
+ `createdAt` datetime DEFAULT NULL,
2126
+ `createdBy` varchar(100) DEFAULT NULL,
2127
+ `modifiedAt` datetime DEFAULT NULL,
2128
+ `modifiedBy` varchar(100) DEFAULT NULL,
2129
+ `historyAccess` tinyint(1) NOT NULL DEFAULT '0',
2130
+ `estimatedTheftValue` decimal(19,4) DEFAULT NULL,
2131
+ `licensePlate` varchar(50) DEFAULT NULL,
2132
+ `suspectDescription` varchar(255) DEFAULT NULL,
2133
+ PRIMARY KEY (`id`),
2134
+ KEY `ixLiveLinkClientId` (`clientId`)
2135
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2136
+
2137
+ DROP TABLE IF EXISTS `liveLinkMedia`;
2138
+ CREATE TABLE `liveLinkMedia` (
2139
+ `id` int NOT NULL AUTO_INCREMENT,
2140
+ `liveLinkId` binary(16) NOT NULL,
2141
+ `fileName` varchar(255) NOT NULL,
2142
+ `fileExtension` varchar(15) DEFAULT NULL,
2143
+ `s3FilesPath` varchar(255) DEFAULT NULL,
2144
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
2145
+ PRIMARY KEY (`id`),
2146
+ UNIQUE KEY `ixu_liveLinkId_fileName` (`liveLinkId`,`fileName`)
2147
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2148
+
2149
+ DROP TABLE IF EXISTS `m2Sync`;
2150
+ CREATE TABLE `m2Sync` (
2151
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
2152
+ `clientId` int DEFAULT NULL,
2153
+ `userId` varchar(255) DEFAULT NULL,
2154
+ `email` varchar(255) DEFAULT NULL,
2155
+ `braintreeCustomerId` varchar(255) DEFAULT NULL,
2156
+ `paymentMethodToken` varchar(255) DEFAULT NULL,
2157
+ `subscriptionId` varchar(255) DEFAULT NULL,
2158
+ `imei` varchar(255) DEFAULT NULL,
2159
+ `syncType` enum('CREATE_CUSTOMER','UPDATE_USER','UPDATE_CLIENT','AVALARA_EXEMPT','AVALARA_EXEMPT_REMOVE','AVALARA_ITEM','CREATE_DEVICE','REMOVE_DEVICE','UPDATE_DEVICE','SUSPEND_DEVICE','UNSUSPEND_DEVICE','CANCEL_DEVICE') DEFAULT NULL,
2160
+ `status` tinyint(1) NOT NULL DEFAULT '0',
2161
+ `createdAt` datetime NOT NULL,
2162
+ PRIMARY KEY (`id`)
2163
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2164
+
2165
+ DROP TABLE IF EXISTS `magento2Gps`;
2166
+ CREATE TABLE `magento2Gps` (
2167
+ `id` int NOT NULL AUTO_INCREMENT,
2168
+ `customerId` varchar(255) DEFAULT NULL,
2169
+ `email` varchar(255) DEFAULT NULL,
2170
+ `customerUpdatedAt` varchar(255) DEFAULT NULL,
2171
+ `createdIn` varchar(255) DEFAULT NULL,
2172
+ `firstName` varchar(255) DEFAULT NULL,
2173
+ `lastName` varchar(255) DEFAULT NULL,
2174
+ `middleName` varchar(255) DEFAULT NULL,
2175
+ `postcode` varchar(255) DEFAULT NULL,
2176
+ `prefix` varchar(255) DEFAULT NULL,
2177
+ `region` varchar(255) DEFAULT NULL,
2178
+ `street` varchar(255) DEFAULT NULL,
2179
+ `city` varchar(255) DEFAULT NULL,
2180
+ `telephone` varchar(255) DEFAULT NULL,
2181
+ `countryId` varchar(255) DEFAULT NULL,
2182
+ `company` varchar(255) DEFAULT NULL,
2183
+ `btAccountId` varchar(255) DEFAULT NULL,
2184
+ `phoneCode` varchar(255) DEFAULT NULL,
2185
+ `phoneCodeCountryId` varchar(255) DEFAULT NULL,
2186
+ `pinCode` varchar(255) DEFAULT NULL,
2187
+ `stripeCustomerId` varchar(255) DEFAULT NULL,
2188
+ `activationCreated` varchar(255) DEFAULT NULL,
2189
+ `imei` varchar(255) DEFAULT NULL,
2190
+ `deviceId` varchar(255) DEFAULT NULL,
2191
+ `deviceType` varchar(255) DEFAULT NULL,
2192
+ `deviceColor` varchar(255) DEFAULT NULL,
2193
+ `btSubscriptionId` varchar(255) DEFAULT NULL,
2194
+ `servicePlanId` varchar(255) DEFAULT NULL,
2195
+ `billingInterval` varchar(255) DEFAULT NULL,
2196
+ `status` varchar(255) DEFAULT NULL,
2197
+ `orderId` varchar(255) DEFAULT NULL,
2198
+ `deviceUpdatedAt` varchar(255) DEFAULT NULL,
2199
+ `deviceCreatedAt` varchar(255) DEFAULT NULL,
2200
+ `importedDevice` varchar(255) DEFAULT NULL,
2201
+ `trackerName` varchar(255) DEFAULT NULL,
2202
+ `trackerUse` varchar(255) DEFAULT NULL,
2203
+ `deviceStatus` varchar(255) DEFAULT NULL,
2204
+ `planCode` varchar(255) DEFAULT NULL,
2205
+ `platformCode` varchar(255) DEFAULT NULL,
2206
+ `platformName` varchar(255) DEFAULT NULL,
2207
+ `stripeCreatedAt` varchar(255) DEFAULT NULL,
2208
+ `stripeUpdatedAt` varchar(255) DEFAULT NULL,
2209
+ `dateCaptured` varchar(255) DEFAULT NULL,
2210
+ `cancelationReason` text,
2211
+ `cancelationCreated` varchar(255) DEFAULT NULL,
2212
+ `cancelationReactivated` varchar(255) DEFAULT NULL,
2213
+ `clientId` varchar(255) DEFAULT NULL,
2214
+ `itemsForRecovery` text,
2215
+ `platform` varchar(255) DEFAULT NULL,
2216
+ PRIMARY KEY (`id`),
2217
+ KEY `ixMagento2GpsImei` (`imei`),
2218
+ KEY `ixMagento2GpsbtSubscriptionId` (`btSubscriptionId`)
2219
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2220
+
2221
+ DROP TABLE IF EXISTS `magento2Plan`;
2222
+ CREATE TABLE `magento2Plan` (
2223
+ `magentoPlanCode` varchar(100) NOT NULL,
2224
+ `magentoBillingInterval` varchar(50) NOT NULL,
2225
+ `planAnnual` tinyint(1) NOT NULL,
2226
+ `planId` varchar(100) NOT NULL,
2227
+ PRIMARY KEY (`magentoPlanCode`,`magentoBillingInterval`),
2228
+ KEY `ixMagento2PlanComposite` (`planId`,`magentoPlanCode`,`magentoBillingInterval`)
2229
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2230
+
2231
+ DROP TABLE IF EXISTS `marketplacePromotion`;
2232
+ CREATE TABLE `marketplacePromotion` (
2233
+ `marketplaceId` varchar(15) NOT NULL,
2234
+ `promotionId` int NOT NULL,
2235
+ PRIMARY KEY (`marketplaceId`,`promotionId`)
2236
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2237
+
2238
+ DROP TABLE IF EXISTS `migration`;
2239
+ CREATE TABLE `migration` (
2240
+ `id` int NOT NULL AUTO_INCREMENT,
2241
+ `timestamp` bigint NOT NULL,
2242
+ `name` varchar(255) NOT NULL,
2243
+ PRIMARY KEY (`id`)
2244
+ ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2245
+
2246
+ DROP TABLE IF EXISTS `mobileNetwork`;
2247
+ CREATE TABLE `mobileNetwork` (
2248
+ `id` smallint NOT NULL AUTO_INCREMENT,
2249
+ `mcc` smallint NOT NULL,
2250
+ `mnc` smallint NOT NULL,
2251
+ `networkName` varchar(255) DEFAULT NULL,
2252
+ `operatorName` varchar(100) DEFAULT NULL,
2253
+ `countryCode` varchar(50) DEFAULT NULL,
2254
+ `countryName` varchar(100) DEFAULT NULL,
2255
+ PRIMARY KEY (`id`)
2256
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2257
+
2258
+ DROP TABLE IF EXISTS `notificationRecipient`;
2259
+ CREATE TABLE `notificationRecipient` (
2260
+ `id` int NOT NULL AUTO_INCREMENT,
2261
+ `clientId` int NOT NULL,
2262
+ `notificationType` tinyint NOT NULL,
2263
+ `recipient` varchar(100) NOT NULL,
2264
+ `isEnabled` tinyint(1) NOT NULL,
2265
+ `isUserProfile` tinyint(1) NOT NULL,
2266
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
2267
+ `modifiedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
2268
+ `dataSourceTypeId` tinyint DEFAULT NULL,
2269
+ `unsubscribed` tinyint(1) NOT NULL DEFAULT '0',
2270
+ `unsubscribedInfo` varchar(256) DEFAULT NULL,
2271
+ `userId` binary(16) DEFAULT NULL,
2272
+ `userAlertConfigurationId` int DEFAULT NULL,
2273
+ `clientAlertConfigurationId` int DEFAULT NULL,
2274
+ PRIMARY KEY (`id`),
2275
+ UNIQUE KEY `ixuNotificationRecipientClientIdRecipientUserId` (`clientId`,`recipient`,`userId`),
2276
+ KEY `ixNotificationRecipientClientIdUserIdNotificationTypeRecipient` (`clientId`,`userId`,`notificationType`,`recipient`),
2277
+ KEY `ixNotificationRecipientNotificationTypeRecipient` (`notificationType`,`recipient`),
2278
+ KEY `ixNotificationRecipientRecipient` (`recipient`),
2279
+ KEY `ixNotificationRecipientIsUserProfile` (`isUserProfile`),
2280
+ KEY `ixNotificationRecipientIsEnabled` (`isEnabled`),
2281
+ KEY `ixNotificationRecipientUserId` (`userId`)
2282
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2283
+
2284
+ DROP TABLE IF EXISTS `orderShipmentInternational`;
2285
+ CREATE TABLE `orderShipmentInternational` (
2286
+ `imei` varchar(15) NOT NULL,
2287
+ `iccid` varchar(50) NOT NULL,
2288
+ `model` varchar(50) NOT NULL,
2289
+ `labelModel` varchar(50) NOT NULL,
2290
+ `partNo` varchar(50) NOT NULL,
2291
+ `serialNo` varchar(50) NOT NULL,
2292
+ `shipNum` varchar(50) NOT NULL,
2293
+ `workOrder` varchar(50) NOT NULL,
2294
+ `cartonNo` varchar(50) NOT NULL,
2295
+ `location` varchar(6) NOT NULL,
2296
+ PRIMARY KEY (`imei`,`shipNum`)
2297
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2298
+
2299
+ DROP TABLE IF EXISTS `organization`;
2300
+ CREATE TABLE `organization` (
2301
+ `id` int NOT NULL AUTO_INCREMENT,
2302
+ `name` varchar(255) NOT NULL,
2303
+ `description` varchar(500) DEFAULT NULL,
2304
+ `websiteUrl` varchar(1000) DEFAULT NULL,
2305
+ `address` varchar(255) DEFAULT NULL,
2306
+ `mainContact` binary(16) NOT NULL,
2307
+ PRIMARY KEY (`id`)
2308
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2309
+
2310
+ DROP TABLE IF EXISTS `plan`;
2311
+ CREATE TABLE `plan` (
2312
+ `id` varchar(50) NOT NULL,
2313
+ `name` varchar(50) NOT NULL,
2314
+ `description` varchar(255) NOT NULL,
2315
+ `billingFrequencyMonths` tinyint NOT NULL,
2316
+ `price` float NOT NULL,
2317
+ `trialPeriod` varchar(25) DEFAULT NULL,
2318
+ `discount` float DEFAULT NULL,
2319
+ `platform` varchar(25) DEFAULT NULL,
2320
+ `planGroup` varchar(25) DEFAULT NULL,
2321
+ `gracePeriod` varchar(25) DEFAULT NULL,
2322
+ `status` char(1) NOT NULL,
2323
+ `platformPrice` float DEFAULT NULL,
2324
+ `servicePlan` varchar(10) DEFAULT NULL,
2325
+ `contractLengthMonths` tinyint NOT NULL,
2326
+ PRIMARY KEY (`id`)
2327
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2328
+
2329
+ DROP TABLE IF EXISTS `position`;
2330
+ CREATE TABLE `position` (
2331
+ `id` bigint NOT NULL AUTO_INCREMENT,
2332
+ `imei` varchar(15) NOT NULL,
2333
+ `lat` decimal(8,6) DEFAULT NULL,
2334
+ `lon` decimal(9,6) DEFAULT NULL,
2335
+ `actualDate` datetime(3) NOT NULL,
2336
+ `speed` float DEFAULT NULL,
2337
+ `odometer` double DEFAULT NULL,
2338
+ `createdAt` datetime(3) NOT NULL,
2339
+ `messageId` binary(16) NOT NULL,
2340
+ `batteryPercentage` smallint DEFAULT NULL,
2341
+ `clientId` int NOT NULL,
2342
+ `address` varchar(255) DEFAULT NULL,
2343
+ `sendTime` datetime(3) DEFAULT NULL,
2344
+ `gpsUtcTime` datetime(3) DEFAULT NULL,
2345
+ `externalBatteryPercentage` smallint DEFAULT NULL,
2346
+ `externalPowerVoltage` float DEFAULT NULL,
2347
+ `azimuth` smallint DEFAULT NULL,
2348
+ `motionDetected` tinyint(1) DEFAULT NULL,
2349
+ `deleted` tinyint(1) DEFAULT '0',
2350
+ PRIMARY KEY (`id`),
2351
+ UNIQUE KEY `ixuPositionMessageId` (`messageId`),
2352
+ KEY `ixPositionClientId_Imei_ActualDate` (`clientId`,`imei`,`actualDate`),
2353
+ KEY `ixPositionClientId_ActualDate` (`clientId`,`actualDate`),
2354
+ KEY `ixPositionImei` (`imei`)
2355
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2356
+
2357
+ DROP TABLE IF EXISTS `promotion`;
2358
+ CREATE TABLE `promotion` (
2359
+ `id` int NOT NULL AUTO_INCREMENT,
2360
+ `name` varchar(255) NOT NULL,
2361
+ `description` varchar(255) NOT NULL,
2362
+ `type` enum('freeService','discount') NOT NULL COMMENT 'The type of promotion: freeService or discount.',
2363
+ `discount` decimal(19,4) DEFAULT NULL COMMENT 'The discount value if the type is discount offered in US Dollars.',
2364
+ `discountBillingCycles` int DEFAULT NULL COMMENT 'The number of billing cycles that the discount will be applied. Required when type is discount',
2365
+ `freeServiceMonths` int DEFAULT NULL COMMENT 'The number of months that the service will be free. Required when type is freeService',
2366
+ `startDate` datetime NOT NULL COMMENT 'The date that the promotion will start',
2367
+ `endDate` datetime DEFAULT NULL COMMENT 'The date that the promotion will end',
2368
+ `status` varchar(25) NOT NULL COMMENT 'The status of the promotion: active, inactive',
2369
+ `bannerText` varchar(255) DEFAULT NULL,
2370
+ `trackerText` varchar(255) DEFAULT NULL,
2371
+ PRIMARY KEY (`id`)
2372
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2373
+
2374
+ DROP TABLE IF EXISTS `promotionHistory`;
2375
+ CREATE TABLE `promotionHistory` (
2376
+ `imei` varchar(15) NOT NULL,
2377
+ `promotionId` int NOT NULL,
2378
+ `clientId` int DEFAULT NULL,
2379
+ `marketPlaceId` varchar(25) DEFAULT NULL COMMENT 'The marketplace of the device at the time the promotion was applied',
2380
+ `asin` varchar(25) DEFAULT NULL,
2381
+ `promotionType` varchar(25) NOT NULL COMMENT 'The type of promotion: freeService or discount.',
2382
+ `promotionDiscount` decimal(19,4) DEFAULT NULL COMMENT 'The discount value if the type is discount offered in US Dollars.',
2383
+ `promotionDiscountBillingCycles` int DEFAULT NULL COMMENT 'The number of billing cycles that the discount will be applied. Required when type is discount',
2384
+ `promotionFreeServiceMonths` int DEFAULT NULL COMMENT 'The number of months that the service will be free. Required when type is freeService',
2385
+ `appliedAt` datetime NOT NULL COMMENT 'The date that the promotion was applied',
2386
+ PRIMARY KEY (`imei`,`promotionId`)
2387
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2388
+
2389
+ DROP TABLE IF EXISTS `region`;
2390
+ CREATE TABLE `region` (
2391
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
2392
+ `countryCode` varchar(255) DEFAULT NULL,
2393
+ `countryName` varchar(255) DEFAULT NULL,
2394
+ `regionName` varchar(255) DEFAULT NULL,
2395
+ `regionCode` varchar(255) DEFAULT NULL,
2396
+ `regionType` varchar(255) DEFAULT NULL,
2397
+ `regionLat` decimal(19,10) DEFAULT NULL,
2398
+ `regionLong` decimal(19,10) DEFAULT NULL,
2399
+ PRIMARY KEY (`id`),
2400
+ KEY `ix_countryName_regionCode` (`countryName`,`regionCode`),
2401
+ KEY `ix_countryCode_regionCode` (`countryCode`,`regionCode`),
2402
+ KEY `ix_countryName_regionName` (`countryName`,`regionName`)
2403
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2404
+
2405
+ DROP TABLE IF EXISTS `reportScheduleConfiguration`;
2406
+ CREATE TABLE `reportScheduleConfiguration` (
2407
+ `id` int NOT NULL AUTO_INCREMENT,
2408
+ `clientId` int NOT NULL,
2409
+ `reportName` varchar(100) NOT NULL,
2410
+ `reportType` varchar(100) NOT NULL,
2411
+ `customReportId` int DEFAULT NULL,
2412
+ `status` varchar(10) NOT NULL DEFAULT 'Active',
2413
+ `emailMessage` varchar(255) DEFAULT NULL,
2414
+ `frequency` varchar(10) DEFAULT NULL,
2415
+ `timeOfDay` time DEFAULT NULL,
2416
+ `daysOfWeek` json DEFAULT NULL,
2417
+ `monthlyOption` varchar(20) DEFAULT NULL,
2418
+ `dayOfMonth` int DEFAULT NULL,
2419
+ `recipients` varchar(255) DEFAULT NULL,
2420
+ `format` varchar(10) DEFAULT NULL,
2421
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
2422
+ `updatedAt` datetime DEFAULT NULL,
2423
+ `parameters` json DEFAULT NULL,
2424
+ PRIMARY KEY (`id`)
2425
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2426
+
2427
+ DROP TABLE IF EXISTS `retailBleTag`;
2428
+ CREATE TABLE `retailBleTag` (
2429
+ `id` binary(16) NOT NULL,
2430
+ `tagId` varchar(50) NOT NULL,
2431
+ `macAddress` varchar(20) NOT NULL,
2432
+ `storeId` binary(16) NOT NULL,
2433
+ `status` varchar(20) NOT NULL DEFAULT 'active',
2434
+ `batteryLevel` smallint DEFAULT NULL,
2435
+ `lastSeenAt` datetime DEFAULT NULL,
2436
+ `lastGatewayId` int DEFAULT NULL,
2437
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2438
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2439
+ PRIMARY KEY (`id`),
2440
+ UNIQUE KEY `ix_tagId` (`tagId`),
2441
+ UNIQUE KEY `ix_macAddress` (`macAddress`),
2442
+ KEY `ix_storeId` (`storeId`)
2443
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2444
+
2445
+ DROP TABLE IF EXISTS `retailGateway`;
2446
+ CREATE TABLE `retailGateway` (
2447
+ `id` binary(16) NOT NULL,
2448
+ `storeId` binary(16) NOT NULL,
2449
+ `zoneId` binary(16) DEFAULT NULL,
2450
+ `macAddress` varchar(20) NOT NULL,
2451
+ `imei` varchar(15) DEFAULT NULL,
2452
+ `name` varchar(100) NOT NULL,
2453
+ `status` varchar(20) NOT NULL DEFAULT 'online',
2454
+ `lastSeenAt` datetime DEFAULT NULL,
2455
+ `firmwareVersion` varchar(20) DEFAULT NULL,
2456
+ `signalStrengthThreshold` smallint DEFAULT NULL,
2457
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2458
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2459
+ PRIMARY KEY (`id`),
2460
+ UNIQUE KEY `ix_macAddress` (`macAddress`),
2461
+ KEY `ix_storeId_status` (`storeId`,`status`),
2462
+ KEY `ix_storeId_zoneId_status` (`storeId`,`zoneId`,`status`)
2463
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2464
+
2465
+ DROP TABLE IF EXISTS `retailIncident`;
2466
+ CREATE TABLE `retailIncident` (
2467
+ `id` binary(16) NOT NULL,
2468
+ `clientId` int NOT NULL,
2469
+ `storeId` binary(16) NOT NULL,
2470
+ `itemId` binary(16) DEFAULT NULL,
2471
+ `type` varchar(20) NOT NULL,
2472
+ `status` varchar(20) NOT NULL,
2473
+ `severity` varchar(20) NOT NULL,
2474
+ `description` varchar(255) NOT NULL,
2475
+ `estimatedLoss` decimal(19,4) DEFAULT NULL,
2476
+ `zoneId` binary(16) DEFAULT NULL,
2477
+ `detectedAt` datetime NOT NULL,
2478
+ `resolvedAt` datetime DEFAULT NULL,
2479
+ `resolvedBy` varchar(50) DEFAULT NULL,
2480
+ `resolution` varchar(255) DEFAULT NULL,
2481
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2482
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2483
+ PRIMARY KEY (`id`),
2484
+ KEY `ix_clientId_storeId` (`clientId`,`storeId`)
2485
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2486
+
2487
+ DROP TABLE IF EXISTS `retailItem`;
2488
+ CREATE TABLE `retailItem` (
2489
+ `id` binary(16) NOT NULL,
2490
+ `bleTagId` binary(16) NOT NULL,
2491
+ `productId` binary(16) NOT NULL,
2492
+ `storeId` binary(16) NOT NULL,
2493
+ `homeZoneId` binary(16) NOT NULL,
2494
+ `currentZoneId` binary(16) DEFAULT NULL,
2495
+ `status` varchar(20) NOT NULL,
2496
+ `batteryLevel` smallint DEFAULT NULL,
2497
+ `lastMovedAt` datetime DEFAULT NULL,
2498
+ `enteredCurrentZoneAt` datetime DEFAULT NULL,
2499
+ `receivedAt` datetime NOT NULL,
2500
+ `soldAt` datetime DEFAULT NULL,
2501
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2502
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2503
+ PRIMARY KEY (`id`),
2504
+ UNIQUE KEY `ix_bleTagId_productId` (`bleTagId`,`productId`),
2505
+ KEY `ix_storeId` (`storeId`)
2506
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2507
+
2508
+ DROP TABLE IF EXISTS `retailItemEvent`;
2509
+ CREATE TABLE `retailItemEvent` (
2510
+ `id` binary(16) NOT NULL,
2511
+ `itemId` binary(16) NOT NULL,
2512
+ `bleTagId` binary(16) NOT NULL,
2513
+ `storeId` binary(16) NOT NULL,
2514
+ `eventType` varchar(20) NOT NULL,
2515
+ `zoneId` binary(16) DEFAULT NULL,
2516
+ `zoneCategory` varchar(50) DEFAULT NULL,
2517
+ `gatewayId` binary(16) DEFAULT NULL,
2518
+ `metadata` json DEFAULT NULL,
2519
+ `timestamp` datetime NOT NULL,
2520
+ `duration` int DEFAULT NULL,
2521
+ PRIMARY KEY (`id`),
2522
+ KEY `ix_bleTagId` (`bleTagId`),
2523
+ KEY `ix_storeId_itemId` (`storeId`,`itemId`)
2524
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2525
+
2526
+ DROP TABLE IF EXISTS `retailProduct`;
2527
+ CREATE TABLE `retailProduct` (
2528
+ `id` binary(16) NOT NULL,
2529
+ `clientId` int NOT NULL,
2530
+ `upc` varchar(12) NOT NULL,
2531
+ `sku` varchar(50) NOT NULL,
2532
+ `name` varchar(100) NOT NULL,
2533
+ `brand` varchar(50) NOT NULL,
2534
+ `category` varchar(50) NOT NULL,
2535
+ `defaultZoneId` binary(16) DEFAULT NULL,
2536
+ `price` decimal(19,4) NOT NULL,
2537
+ `imageUrl` varchar(255) DEFAULT NULL,
2538
+ `attributes` json DEFAULT NULL,
2539
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2540
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2541
+ PRIMARY KEY (`id`),
2542
+ UNIQUE KEY `ix_clientId_upc` (`clientId`,`upc`),
2543
+ KEY `ix_clientId_brand_category` (`clientId`,`brand`,`category`)
2544
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2545
+
2546
+ DROP TABLE IF EXISTS `retailStore`;
2547
+ CREATE TABLE `retailStore` (
2548
+ `id` binary(16) NOT NULL,
2549
+ `clientId` int NOT NULL,
2550
+ `storeNumber` varchar(15) DEFAULT NULL,
2551
+ `name` varchar(100) NOT NULL,
2552
+ `address` varchar(255) NOT NULL,
2553
+ `city` varchar(50) NOT NULL,
2554
+ `state` varchar(50) NOT NULL,
2555
+ `zipCode` varchar(30) NOT NULL,
2556
+ `country` varchar(50) NOT NULL,
2557
+ `timezone` varchar(100) NOT NULL,
2558
+ `region` varchar(50) DEFAULT NULL,
2559
+ `businessHours` json DEFAULT NULL,
2560
+ `status` varchar(20) NOT NULL DEFAULT 'online',
2561
+ `floorplanUrl` varchar(255) DEFAULT NULL,
2562
+ `latitude` decimal(8,6) DEFAULT NULL,
2563
+ `longitude` decimal(9,6) DEFAULT NULL,
2564
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2565
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2566
+ PRIMARY KEY (`id`),
2567
+ KEY `ix_clientId_storeNumber` (`clientId`,`storeNumber`),
2568
+ KEY `ix_clientId_region_status` (`clientId`,`region`,`status`)
2569
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2570
+
2571
+ DROP TABLE IF EXISTS `retailTrainingSet`;
2572
+ CREATE TABLE `retailTrainingSet` (
2573
+ `id` binary(16) NOT NULL,
2574
+ `clientId` int NOT NULL,
2575
+ `storeId` binary(16) NOT NULL,
2576
+ `type` varchar(100) NOT NULL,
2577
+ `baseTrainingRunId` binary(16) DEFAULT NULL,
2578
+ `deviceMacAddress` varchar(20) NOT NULL,
2579
+ `performedBy` json DEFAULT NULL,
2580
+ `status` varchar(100) NOT NULL DEFAULT 'in_progress',
2581
+ `startedAt` datetime DEFAULT NULL,
2582
+ `submittedAt` datetime DEFAULT NULL,
2583
+ `completedAt` datetime DEFAULT NULL,
2584
+ `segmentCount` int DEFAULT NULL,
2585
+ `totalDuration` int DEFAULT NULL,
2586
+ `coveredZoneIds` json DEFAULT NULL,
2587
+ `segments` json DEFAULT NULL,
2588
+ `notes` varchar(255) DEFAULT NULL,
2589
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2590
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2591
+ PRIMARY KEY (`id`),
2592
+ KEY `ix_clientId_storeId` (`clientId`,`storeId`)
2593
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2594
+
2595
+ DROP TABLE IF EXISTS `retailZone`;
2596
+ CREATE TABLE `retailZone` (
2597
+ `id` binary(16) NOT NULL,
2598
+ `storeId` binary(16) NOT NULL,
2599
+ `name` varchar(100) NOT NULL,
2600
+ `code` varchar(50) NOT NULL,
2601
+ `category` varchar(50) NOT NULL,
2602
+ `department` varchar(100) DEFAULT NULL,
2603
+ `sortOrder` int NOT NULL,
2604
+ `capacity` int DEFAULT NULL,
2605
+ `coordinates` json DEFAULT NULL,
2606
+ `color` varchar(25) DEFAULT NULL,
2607
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
2608
+ `updatedAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
2609
+ PRIMARY KEY (`id`),
2610
+ KEY `ix_storeId_category` (`storeId`,`category`)
2611
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2612
+
2613
+ DROP TABLE IF EXISTS `securityRole`;
2614
+ CREATE TABLE `securityRole` (
2615
+ `id` tinyint NOT NULL AUTO_INCREMENT,
2616
+ `key` varchar(25) NOT NULL,
2617
+ `name` varchar(50) NOT NULL,
2618
+ `description` varchar(100) NOT NULL,
2619
+ `ordinalPosition` tinyint NOT NULL,
2620
+ PRIMARY KEY (`id`)
2621
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2622
+
2623
+ DROP TABLE IF EXISTS `serviceProvider`;
2624
+ CREATE TABLE `serviceProvider` (
2625
+ `id` smallint NOT NULL AUTO_INCREMENT,
2626
+ `name` varchar(100) NOT NULL,
2627
+ `description` varchar(1000) NOT NULL,
2628
+ `loginUrl` varchar(1000) DEFAULT NULL,
2629
+ `apn` varchar(50) DEFAULT NULL,
2630
+ PRIMARY KEY (`id`)
2631
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2632
+
2633
+ DROP TABLE IF EXISTS `serviceProviderProduct`;
2634
+ CREATE TABLE `serviceProviderProduct` (
2635
+ `id` tinyint NOT NULL AUTO_INCREMENT,
2636
+ `productId` varchar(100) NOT NULL,
2637
+ `name` varchar(100) NOT NULL,
2638
+ `serviceProviderProductTypeId` tinyint DEFAULT NULL,
2639
+ `serviceProviderProductNetworkId` tinyint DEFAULT NULL,
2640
+ `mbIncluded` smallint DEFAULT NULL,
2641
+ `bundleCost` decimal(19,4) DEFAULT NULL,
2642
+ PRIMARY KEY (`id`),
2643
+ KEY `ixServiceProviderProductServiceProviderProductTypeId` (`serviceProviderProductTypeId`),
2644
+ KEY `ixServiceProviderProductServiceProviderProductNetworkId` (`serviceProviderProductNetworkId`)
2645
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2646
+
2647
+ DROP TABLE IF EXISTS `serviceProviderProductNetwork`;
2648
+ CREATE TABLE `serviceProviderProductNetwork` (
2649
+ `id` tinyint NOT NULL AUTO_INCREMENT,
2650
+ `name` varchar(100) NOT NULL,
2651
+ `description` varchar(100) NOT NULL,
2652
+ PRIMARY KEY (`id`)
2653
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2654
+
2655
+ DROP TABLE IF EXISTS `serviceProviderProductType`;
2656
+ CREATE TABLE `serviceProviderProductType` (
2657
+ `id` tinyint NOT NULL AUTO_INCREMENT,
2658
+ `name` varchar(100) NOT NULL,
2659
+ `description` varchar(100) NOT NULL,
2660
+ PRIMARY KEY (`id`)
2661
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2662
+
2663
+ DROP TABLE IF EXISTS `sim`;
2664
+ CREATE TABLE `sim` (
2665
+ `id` int NOT NULL AUTO_INCREMENT,
2666
+ `imei` varchar(15) DEFAULT NULL,
2667
+ `iccid` varchar(25) DEFAULT NULL,
2668
+ `carrier` tinyint DEFAULT NULL,
2669
+ `phone` varchar(25) DEFAULT NULL,
2670
+ `deviceTypeId` smallint DEFAULT NULL,
2671
+ `serviceProviderProductId` tinyint DEFAULT NULL,
2672
+ `isValid` tinyint(1) NOT NULL DEFAULT '1',
2673
+ `realModel` varchar(50) DEFAULT NULL,
2674
+ `po` varchar(25) DEFAULT NULL,
2675
+ `outOfInventory` tinyint(1) NOT NULL DEFAULT '0',
2676
+ `apn` varchar(50) DEFAULT NULL,
2677
+ `createdAt` datetime DEFAULT NULL,
2678
+ `modifiedAt` datetime DEFAULT NULL,
2679
+ PRIMARY KEY (`id`),
2680
+ KEY `ixImeiIccidCarrierProductId` (`serviceProviderProductId`),
2681
+ KEY `ixImeiIccidCarrierModifiedAt` (`modifiedAt`),
2682
+ KEY `ixImeiIccidCarrierImei` (`imei`),
2683
+ KEY `ixImeiIccidCarrierIccid` (`iccid`),
2684
+ KEY `ixImeiIccidCarrierDeviceTypeId` (`deviceTypeId`),
2685
+ KEY `ixImeiIccidCarrierCarrier` (`carrier`)
2686
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2687
+
2688
+ DROP TABLE IF EXISTS `stripeAddonMapping`;
2689
+ CREATE TABLE `stripeAddonMapping` (
2690
+ `priceId` varchar(100) NOT NULL,
2691
+ `internalAddonId` varchar(100) NOT NULL,
2692
+ `name` varchar(100) NOT NULL,
2693
+ `billingInterval` smallint NOT NULL,
2694
+ PRIMARY KEY (`priceId`),
2695
+ KEY `ixStripeAddonMappingBillingInterval` (`billingInterval`)
2696
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2697
+
2698
+ DROP TABLE IF EXISTS `stripePriceMapping`;
2699
+ CREATE TABLE `stripePriceMapping` (
2700
+ `priceId` varchar(100) NOT NULL,
2701
+ `internalPlanId` varchar(100) NOT NULL,
2702
+ `validFrom` date DEFAULT NULL,
2703
+ `validUntil` date DEFAULT NULL,
2704
+ `isActivePrice` tinyint(1) NOT NULL,
2705
+ PRIMARY KEY (`priceId`),
2706
+ KEY `ixStripePriceMappingIsActivePriceInternalPlanId` (`isActivePrice`,`internalPlanId`),
2707
+ KEY `ixStripePriceMappingInternalPlanIdValidFromValidUntil` (`internalPlanId`,`validFrom`,`validUntil`)
2708
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2709
+
2710
+ DROP TABLE IF EXISTS `tag`;
2711
+ CREATE TABLE `tag` (
2712
+ `id` int NOT NULL AUTO_INCREMENT,
2713
+ `clientId` int NOT NULL,
2714
+ `name` varchar(50) NOT NULL,
2715
+ `description` varchar(255) DEFAULT NULL,
2716
+ `color` varchar(32) DEFAULT NULL,
2717
+ `createdBy` varchar(50) NOT NULL,
2718
+ `createdAt` datetime NOT NULL,
2719
+ `modifiedBy` varchar(50) DEFAULT NULL,
2720
+ `modifiedAt` datetime DEFAULT NULL,
2721
+ `metadata` json DEFAULT NULL,
2722
+ `isSecurityGroup` tinyint(1) NOT NULL DEFAULT '0',
2723
+ PRIMARY KEY (`id`),
2724
+ UNIQUE KEY `ixTagClientIdName` (`clientId`,`name`)
2725
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2726
+
2727
+ DROP TABLE IF EXISTS `task`;
2728
+ CREATE TABLE `task` (
2729
+ `id` int NOT NULL AUTO_INCREMENT,
2730
+ `taskScheduleId` int NOT NULL,
2731
+ `imei` varchar(15) NOT NULL,
2732
+ `clientId` int NOT NULL,
2733
+ `dueDate` datetime DEFAULT NULL,
2734
+ `dueOdometer` double DEFAULT NULL,
2735
+ `dueActiveHours` double DEFAULT NULL,
2736
+ `startDate` datetime DEFAULT NULL,
2737
+ `startingOdometer` double DEFAULT NULL,
2738
+ `startingActiveHours` double DEFAULT NULL,
2739
+ `status` varchar(10) NOT NULL DEFAULT 'pending',
2740
+ `createdAt` datetime NOT NULL,
2741
+ `pastDueAt` datetime DEFAULT NULL,
2742
+ `completedAt` datetime DEFAULT NULL,
2743
+ `completionNotes` text,
2744
+ `completionOdometer` double DEFAULT NULL,
2745
+ `completionActiveHours` double DEFAULT NULL,
2746
+ `completedBy` varchar(50) DEFAULT NULL,
2747
+ `modifiedAt` datetime DEFAULT NULL,
2748
+ `modifiedBy` varchar(50) DEFAULT NULL,
2749
+ `queuedAt` datetime DEFAULT NULL,
2750
+ `predictedDueDate` datetime DEFAULT NULL,
2751
+ `deletedAt` datetime DEFAULT NULL,
2752
+ `deletedBy` varchar(50) DEFAULT NULL,
2753
+ `completionMetadata` json DEFAULT NULL,
2754
+ `includeTimeInCompletedAt` tinyint(1) DEFAULT NULL,
2755
+ `assignedTo` varchar(50) DEFAULT NULL,
2756
+ `timeSpent` double DEFAULT NULL,
2757
+ `cost` double DEFAULT NULL,
2758
+ PRIMARY KEY (`id`),
2759
+ KEY `ixTask_Status` (`status`),
2760
+ KEY `ixTask_ClientId` (`clientId`),
2761
+ KEY `ixTask_Imei` (`imei`),
2762
+ KEY `ixTask_TaskScheduleId` (`taskScheduleId`)
2763
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2764
+
2765
+ DROP TABLE IF EXISTS `taskSchedule`;
2766
+ CREATE TABLE `taskSchedule` (
2767
+ `id` int NOT NULL AUTO_INCREMENT,
2768
+ `clientId` int NOT NULL,
2769
+ `title` varchar(50) NOT NULL,
2770
+ `description` varchar(255) NOT NULL,
2771
+ `repeats` tinyint(1) NOT NULL DEFAULT '0',
2772
+ `dueDate` datetime DEFAULT NULL,
2773
+ `dueOdometer` double DEFAULT NULL,
2774
+ `dueActiveHours` double DEFAULT NULL,
2775
+ `intervalDays` double DEFAULT NULL,
2776
+ `intervalStartDate` datetime DEFAULT NULL,
2777
+ `intervalOdometer` double DEFAULT NULL,
2778
+ `intervalStartingOdometer` double DEFAULT NULL,
2779
+ `intervalActiveHours` double DEFAULT NULL,
2780
+ `intervalStartingActiveHours` double DEFAULT NULL,
2781
+ `notes` text,
2782
+ `createdBy` varchar(50) NOT NULL,
2783
+ `createdAt` datetime NOT NULL,
2784
+ `modifiedBy` varchar(50) DEFAULT NULL,
2785
+ `modifiedAt` datetime DEFAULT NULL,
2786
+ `deletedBy` varchar(50) DEFAULT NULL,
2787
+ `deletedAt` datetime DEFAULT NULL,
2788
+ `status` varchar(10) NOT NULL DEFAULT 'active',
2789
+ `assignedTo` varchar(50) DEFAULT NULL,
2790
+ PRIMARY KEY (`id`),
2791
+ KEY `ixTaskScheduleStatus` (`status`),
2792
+ KEY `ixTaskScheduleClientId` (`clientId`)
2793
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2794
+
2795
+ DROP TABLE IF EXISTS `ticketManager`;
2796
+ CREATE TABLE `ticketManager` (
2797
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT,
2798
+ `imei` varchar(15) NOT NULL,
2799
+ `clientId` int NOT NULL,
2800
+ `type` varchar(256) NOT NULL,
2801
+ `sentAt` datetime NOT NULL,
2802
+ `expiresAt` datetime NOT NULL,
2803
+ `source` varchar(256) NOT NULL,
2804
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
2805
+ PRIMARY KEY (`id`),
2806
+ KEY `ixTicketManagerImeiTypeSourceExpiresAt` (`imei`,`type`,`source`,`expiresAt`)
2807
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2808
+
2809
+ DROP TABLE IF EXISTS `trip`;
2810
+ CREATE TABLE `trip` (
2811
+ `id` bigint NOT NULL AUTO_INCREMENT,
2812
+ `tripGuid` binary(16) NOT NULL,
2813
+ `imei` varchar(15) NOT NULL,
2814
+ `startDate` datetime(3) NOT NULL,
2815
+ `endDate` datetime(3) DEFAULT NULL,
2816
+ `distance` float NOT NULL,
2817
+ `startLat` decimal(8,6) NOT NULL,
2818
+ `startLon` decimal(9,6) NOT NULL,
2819
+ `endLat` decimal(8,6) DEFAULT NULL,
2820
+ `endLon` decimal(9,6) DEFAULT NULL,
2821
+ `createdAt` datetime(3) NOT NULL,
2822
+ `startAddress` varchar(255) NOT NULL,
2823
+ `endAddress` varchar(255) DEFAULT NULL,
2824
+ `positionStart` varchar(255) NOT NULL,
2825
+ `positionEnd` varchar(255) DEFAULT NULL,
2826
+ `tripCompletionStatusId` tinyint NOT NULL DEFAULT '1',
2827
+ `clientId` int NOT NULL,
2828
+ `duration` int NOT NULL,
2829
+ `tripType` tinyint NOT NULL,
2830
+ `startMessageId` binary(16) NOT NULL,
2831
+ `endMessageId` binary(16) DEFAULT NULL,
2832
+ `startSendTimeMessage` datetime(3) DEFAULT NULL,
2833
+ `endSendTimeMessage` datetime(3) DEFAULT NULL,
2834
+ `deleted` tinyint(1) DEFAULT '0',
2835
+ `startOdometer` double DEFAULT NULL,
2836
+ `endOdometer` double DEFAULT NULL,
2837
+ `startPositionId` bigint DEFAULT NULL,
2838
+ `endPositionId` bigint DEFAULT NULL,
2839
+ PRIMARY KEY (`id`),
2840
+ UNIQUE KEY `ixuTripGuid` (`tripGuid`),
2841
+ KEY `ixTripClientIdImeiStartDate` (`clientId`,`imei`,`startDate`),
2842
+ KEY `ixCreatedAt` (`createdAt`),
2843
+ KEY `ixTripEndDate` (`endDate`),
2844
+ KEY `ixTripStartDate` (`startDate`),
2845
+ KEY `ixTripImei` (`imei`)
2846
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2847
+
2848
+ DROP TABLE IF EXISTS `tripCompletionStatus`;
2849
+ CREATE TABLE `tripCompletionStatus` (
2850
+ `id` tinyint NOT NULL AUTO_INCREMENT,
2851
+ `name` varchar(50) NOT NULL,
2852
+ `description` varchar(500) NOT NULL,
2853
+ `statusId` tinyint(1) NOT NULL DEFAULT '1',
2854
+ PRIMARY KEY (`id`)
2855
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2856
+
2857
+ DROP TABLE IF EXISTS `tripPosition`;
2858
+ CREATE TABLE `tripPosition` (
2859
+ `tripId` bigint NOT NULL,
2860
+ `positionId` bigint NOT NULL,
2861
+ PRIMARY KEY (`tripId`,`positionId`)
2862
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2863
+
2864
+ DROP TABLE IF EXISTS `tripStatus`;
2865
+ CREATE TABLE `tripStatus` (
2866
+ `imei` varchar(15) NOT NULL,
2867
+ `clientId` int NOT NULL,
2868
+ `tripGuid` binary(16) DEFAULT NULL,
2869
+ `tripStartDate` datetime DEFAULT NULL,
2870
+ PRIMARY KEY (`imei`)
2871
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2872
+
2873
+ DROP TABLE IF EXISTS `user`;
2874
+ CREATE TABLE `user` (
2875
+ `id` binary(16) NOT NULL,
2876
+ `numberId` int NOT NULL AUTO_INCREMENT,
2877
+ `firstName` varchar(100) NOT NULL,
2878
+ `lastName` varchar(100) NOT NULL,
2879
+ `companyName` varchar(255) DEFAULT NULL,
2880
+ `telephone` varchar(20) DEFAULT NULL,
2881
+ `street` varchar(255) DEFAULT NULL,
2882
+ `postalCode` varchar(30) DEFAULT NULL,
2883
+ `city` varchar(50) DEFAULT NULL,
2884
+ `region` varchar(50) DEFAULT NULL,
2885
+ `email` varchar(255) NOT NULL,
2886
+ `userName` varchar(255) NOT NULL,
2887
+ `createdAt` datetime DEFAULT NULL,
2888
+ `modifiedAt` datetime DEFAULT NULL,
2889
+ `status` char(1) DEFAULT 'A',
2890
+ `clientId` int NOT NULL,
2891
+ `pincode` varchar(20) DEFAULT NULL,
2892
+ `isAdmin` tinyint(1) NOT NULL,
2893
+ `countryId` smallint DEFAULT NULL,
2894
+ `telephoneCountryId` smallint DEFAULT NULL,
2895
+ `dataSourceTypeId` tinyint DEFAULT NULL,
2896
+ `preferredUserName` varchar(255) DEFAULT NULL,
2897
+ `lastLoginAt` datetime DEFAULT NULL,
2898
+ `emailVerified` tinyint(1) NOT NULL DEFAULT '1',
2899
+ `lat` decimal(8,6) DEFAULT NULL,
2900
+ `lon` decimal(9,6) DEFAULT NULL,
2901
+ `userAgreementAcceptedAt` datetime DEFAULT NULL,
2902
+ `fullPhoneNumber` varchar(20) DEFAULT NULL,
2903
+ `profile` json DEFAULT NULL,
2904
+ PRIMARY KEY (`id`),
2905
+ UNIQUE KEY `IDX_8eb27834bf79e32decf36fc013` (`numberId`),
2906
+ KEY `ixCountryIdRegion` (`countryId`,`region`),
2907
+ KEY `ixRegion` (`region`),
2908
+ KEY `ixUserTelephone` (`telephone`),
2909
+ KEY `ixUserUserName` (`userName`),
2910
+ KEY `ixUserStatus` (`status`),
2911
+ KEY `ixUserLastLoginAt` (`lastLoginAt`),
2912
+ KEY `ixUserEmail` (`email`),
2913
+ KEY `ixUserCreatedAt` (`createdAt`),
2914
+ KEY `ixUserClientId` (`clientId`),
2915
+ KEY `ixUserEmailLower` ((lower(`email`))),
2916
+ KEY `ixUserNameLower` ((lower(`userName`))),
2917
+ KEY `ixPreferredUserNameLower` ((lower(`preferredUserName`)))
2918
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2919
+
2920
+ DROP TABLE IF EXISTS `userActivation`;
2921
+ CREATE TABLE `userActivation` (
2922
+ `id` int NOT NULL AUTO_INCREMENT,
2923
+ `createdAt` datetime DEFAULT NULL,
2924
+ `status` char(1) DEFAULT 'A',
2925
+ `userId` binary(16) NOT NULL,
2926
+ `legacyCreatedAt` datetime DEFAULT NULL,
2927
+ `clientId` int NOT NULL,
2928
+ PRIMARY KEY (`id`),
2929
+ KEY `ixUserActivationUserId` (`userId`)
2930
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2931
+
2932
+ DROP TABLE IF EXISTS `userActivationDevice`;
2933
+ CREATE TABLE `userActivationDevice` (
2934
+ `id` int NOT NULL AUTO_INCREMENT,
2935
+ `userActivationId` int NOT NULL,
2936
+ `deviceId` int NOT NULL,
2937
+ `imei` varchar(15) NOT NULL,
2938
+ `model` varchar(50) DEFAULT NULL,
2939
+ `billingInterval` varchar(25) DEFAULT NULL,
2940
+ `deviceName` varchar(255) DEFAULT NULL,
2941
+ `createdAt` datetime DEFAULT NULL,
2942
+ `modifiedAt` datetime DEFAULT NULL,
2943
+ `status` char(1) DEFAULT 'A',
2944
+ `trackingReason` varchar(500) DEFAULT NULL,
2945
+ `deviceColor` varchar(25) DEFAULT NULL,
2946
+ `notificationByEmail` tinyint(1) DEFAULT NULL,
2947
+ `notificationBySms` tinyint(1) DEFAULT NULL,
2948
+ `planAnnual` tinyint(1) DEFAULT NULL,
2949
+ `dataSourceTypeId` tinyint DEFAULT NULL,
2950
+ `subscriptionId` varchar(50) DEFAULT NULL,
2951
+ `platform` varchar(25) DEFAULT NULL,
2952
+ `eventType` varchar(50) DEFAULT NULL,
2953
+ `planCode` varchar(50) DEFAULT NULL,
2954
+ `servicePlan` varchar(50) DEFAULT NULL,
2955
+ `clientId` int DEFAULT NULL,
2956
+ PRIMARY KEY (`id`),
2957
+ KEY `ixUserActivationDeviceImeiCreatedAt` (`imei`,`createdAt`),
2958
+ KEY `ixUserActivationDeviceActivationId` (`userActivationId`),
2959
+ KEY `ixUserActivationDeviceSubscriptionId` (`subscriptionId`),
2960
+ KEY `ixUserActivationDeviceDeviceId` (`deviceId`),
2961
+ KEY `ixUserActivationDeviceCreatedAt` (`createdAt`)
2962
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2963
+
2964
+ DROP TABLE IF EXISTS `userActivationEvent`;
2965
+ CREATE TABLE `userActivationEvent` (
2966
+ `userId` binary(16) NOT NULL,
2967
+ `eventId` binary(16) NOT NULL,
2968
+ `eventName` text NOT NULL,
2969
+ `eventValue` text,
2970
+ `eventMetadata` text,
2971
+ `createdAt` datetime NOT NULL,
2972
+ `platform` varchar(25) DEFAULT NULL,
2973
+ `ip` text,
2974
+ `userAgent` text,
2975
+ PRIMARY KEY (`userId`,`eventId`)
2976
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
2977
+
2978
+ DROP TABLE IF EXISTS `userActivationMetric`;
2979
+ CREATE TABLE `userActivationMetric` (
2980
+ `id` int NOT NULL AUTO_INCREMENT,
2981
+ `userId` binary(16) NOT NULL,
2982
+ `firstName` text NOT NULL,
2983
+ `lastName` text NOT NULL,
2984
+ `email` text NOT NULL,
2985
+ `phone` text,
2986
+ `trackingReason` text,
2987
+ `companyName` text,
2988
+ `role` text,
2989
+ `industry` text,
2990
+ `devicesActivatingCategory` text,
2991
+ `assetsCountRange` text,
2992
+ `devicesActivatingCount` decimal(10,0) DEFAULT NULL,
2993
+ `plan` text,
2994
+ `usersInvitedCount` decimal(10,0) DEFAULT NULL,
2995
+ `meetingScheduled` tinyint(1) DEFAULT NULL,
2996
+ `createdAt` datetime NOT NULL,
2997
+ `modifiedAt` datetime DEFAULT NULL,
2998
+ `planAnnual` text,
2999
+ `planId` text,
3000
+ `spyEnvironment` text,
3001
+ `jarvisScore` int DEFAULT NULL,
3002
+ `enrichmentCompanyDescription` text,
3003
+ `jarvisEnrichmentCompanyEin` text,
3004
+ `enrichmentCompanyEmployees` text,
3005
+ `enrichmentCompanyIndustry` text,
3006
+ `enrichmentCompanyLocation` text,
3007
+ `enrichmentCompanyName` text,
3008
+ `enrichmentCompanyRevenue` text,
3009
+ `enrichmentPrivateDomain` text,
3010
+ `enrichmentPublicTicker` text,
3011
+ `enrichmentRole` text,
3012
+ `enrichmentTags` text,
3013
+ `jenrichmentTitle` text,
3014
+ `enrichmentVerifiedEmployment` text,
3015
+ PRIMARY KEY (`id`),
3016
+ UNIQUE KEY `ixuUserActivationMetricUserId` (`userId`)
3017
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3018
+
3019
+ DROP TABLE IF EXISTS `userAlertComplain`;
3020
+ CREATE TABLE `userAlertComplain` (
3021
+ `id` int NOT NULL AUTO_INCREMENT,
3022
+ `userId` binary(16) NOT NULL,
3023
+ `alertTypeId` smallint NOT NULL,
3024
+ `clientId` int NOT NULL,
3025
+ `email` varchar(255) NOT NULL,
3026
+ `reason` varchar(25) NOT NULL,
3027
+ `createdAt` datetime NOT NULL,
3028
+ PRIMARY KEY (`id`),
3029
+ UNIQUE KEY `ixuUserAlertComplainUserIdAlertTypeId` (`userId`,`alertTypeId`)
3030
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3031
+
3032
+ DROP TABLE IF EXISTS `userAlertConfiguration`;
3033
+ CREATE TABLE `userAlertConfiguration` (
3034
+ `id` int NOT NULL AUTO_INCREMENT,
3035
+ `userId` binary(16) NOT NULL,
3036
+ `smsNotification` tinyint(1) DEFAULT NULL,
3037
+ `emailNotification` tinyint(1) DEFAULT NULL,
3038
+ `alertTypeId` smallint NOT NULL,
3039
+ `alertValue` varchar(10) DEFAULT NULL,
3040
+ `appNotification` tinyint(1) DEFAULT '1',
3041
+ `dataSourceTypeId` tinyint DEFAULT NULL,
3042
+ `pushNotification` tinyint(1) NOT NULL DEFAULT '1',
3043
+ `alertMetadata` varchar(255) DEFAULT NULL,
3044
+ `filter` json DEFAULT NULL,
3045
+ `enabled` tinyint(1) DEFAULT '1',
3046
+ `createdBy` varchar(100) DEFAULT NULL,
3047
+ `name` varchar(100) DEFAULT NULL,
3048
+ PRIMARY KEY (`id`),
3049
+ KEY `ixUserAlertConfigurationUserIdAlertTypeId` (`userId`,`alertTypeId`)
3050
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3051
+
3052
+ DROP TABLE IF EXISTS `userAlertNotificationsConfig`;
3053
+ CREATE TABLE `userAlertNotificationsConfig` (
3054
+ `id` int NOT NULL AUTO_INCREMENT,
3055
+ `clientAlertConfigurationId` int NOT NULL,
3056
+ `userId` binary(16) NOT NULL,
3057
+ `smsNotification` tinyint(1) NOT NULL DEFAULT '1',
3058
+ `emailNotification` tinyint(1) NOT NULL DEFAULT '1',
3059
+ `appNotification` tinyint(1) NOT NULL DEFAULT '1',
3060
+ `pushNotification` tinyint(1) NOT NULL DEFAULT '1',
3061
+ PRIMARY KEY (`id`),
3062
+ UNIQUE KEY `ixUserIdClientAlertConfigurationId` (`userId`,`clientAlertConfigurationId`),
3063
+ KEY `ixClientAlertConfigurationId` (`clientAlertConfigurationId`)
3064
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3065
+
3066
+ DROP TABLE IF EXISTS `userAppFeedback`;
3067
+ CREATE TABLE `userAppFeedback` (
3068
+ `id` int NOT NULL AUTO_INCREMENT,
3069
+ `userId` binary(16) NOT NULL,
3070
+ `platform` varchar(25) NOT NULL,
3071
+ `appVersion` varchar(20) NOT NULL,
3072
+ `feedback` varchar(2000) DEFAULT NULL,
3073
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
3074
+ `amazonReviewDate` datetime DEFAULT NULL,
3075
+ PRIMARY KEY (`id`),
3076
+ KEY `ixUserAppFeedbackUserId` (`userId`)
3077
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3078
+
3079
+ DROP TABLE IF EXISTS `userAppIncident`;
3080
+ CREATE TABLE `userAppIncident` (
3081
+ `id` int NOT NULL AUTO_INCREMENT,
3082
+ `userId` binary(16) NOT NULL,
3083
+ `userName` varchar(50) DEFAULT NULL,
3084
+ `userEmail` varchar(255) DEFAULT NULL,
3085
+ `deviceOs` varchar(15) NOT NULL,
3086
+ `deviceManufacturer` varchar(100) DEFAULT NULL,
3087
+ `deviceModel` varchar(100) DEFAULT NULL,
3088
+ `stage` varchar(25) NOT NULL,
3089
+ `appVersion` varchar(25) NOT NULL,
3090
+ `createdAt` datetime NOT NULL,
3091
+ `errorMessage` text,
3092
+ `errorFirstReceivedAt` datetime DEFAULT NULL,
3093
+ `errorReceivedAt` datetime DEFAULT NULL,
3094
+ `deviceJailbroken` tinyint(1) DEFAULT NULL,
3095
+ `deviceOsVersion` varchar(20) DEFAULT NULL,
3096
+ `deviceFreeMemory` int DEFAULT NULL,
3097
+ `deviceTotalMemory` int DEFAULT NULL,
3098
+ `deviceCharging` tinyint(1) DEFAULT NULL,
3099
+ `deviceBatteryLevel` smallint DEFAULT NULL,
3100
+ `deviceNetworkAccess` varchar(100) DEFAULT NULL,
3101
+ `appActiveScreen` varchar(50) DEFAULT NULL,
3102
+ `appInForeground` tinyint(1) DEFAULT NULL,
3103
+ `appDurationInForeground` int DEFAULT NULL,
3104
+ `appBundleId` varchar(500) DEFAULT NULL,
3105
+ `incidentUrl` varchar(1000) DEFAULT NULL,
3106
+ `errorId` varchar(100) DEFAULT NULL,
3107
+ PRIMARY KEY (`id`),
3108
+ UNIQUE KEY `ixuUserAppIncidentUserIdErrorId` (`userId`,`errorId`),
3109
+ KEY `ixUserAppIncidentErrorId` (`errorId`),
3110
+ KEY `ixUserAppIncidentCreatedAt` (`createdAt`)
3111
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3112
+
3113
+ DROP TABLE IF EXISTS `userAuthorizedBoundary`;
3114
+ CREATE TABLE `userAuthorizedBoundary` (
3115
+ `clientId` int NOT NULL,
3116
+ `userId` binary(16) NOT NULL,
3117
+ `boundaryId` int NOT NULL,
3118
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
3119
+ PRIMARY KEY (`clientId`,`userId`,`boundaryId`),
3120
+ KEY `ixUserAuthorizedBoundaryBoundaryIdUserId` (`boundaryId`,`userId`),
3121
+ KEY `ixUserAuthorizedBoundaryUserIdBoundaryId` (`userId`,`boundaryId`)
3122
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3123
+
3124
+ DROP TABLE IF EXISTS `userAuthorizedDevice`;
3125
+ CREATE TABLE `userAuthorizedDevice` (
3126
+ `clientId` int NOT NULL,
3127
+ `userId` binary(16) NOT NULL,
3128
+ `imei` varchar(15) NOT NULL,
3129
+ `createdAt` datetime DEFAULT CURRENT_TIMESTAMP,
3130
+ PRIMARY KEY (`clientId`,`userId`,`imei`),
3131
+ KEY `ixUserAuthorizedDeviceImeiUserId` (`imei`,`userId`),
3132
+ KEY `ixUserAuthorizedDeviceUserIdImei` (`userId`,`imei`)
3133
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3134
+
3135
+ DROP TABLE IF EXISTS `userCancellationDueDevice`;
3136
+ CREATE TABLE `userCancellationDueDevice` (
3137
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
3138
+ `imei` varchar(15) NOT NULL,
3139
+ `clientId` int NOT NULL,
3140
+ `subscriptionId` varchar(256) DEFAULT NULL,
3141
+ `code` varchar(256) NOT NULL,
3142
+ `createdBy` varchar(256) NOT NULL,
3143
+ `displayOrder` smallint DEFAULT NULL,
3144
+ `scheduledAt` datetime NOT NULL,
3145
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
3146
+ PRIMARY KEY (`id`),
3147
+ KEY `ix_userCancellationDueDeviceCodeCreatedBy` (`code`,`createdBy`),
3148
+ KEY `ix_userCancellationDueDeviceCreatedByScheduledAt` (`createdBy`,`scheduledAt`),
3149
+ KEY `ix_userCancellationDueDeviceCodeScheduledAt` (`code`,`scheduledAt`),
3150
+ KEY `ix_userCancellationDueDeviceClientIdScheduledAt` (`clientId`,`scheduledAt`),
3151
+ KEY `ix_userCancellationDueDeviceSubscriptionIdScheduledAt` (`subscriptionId`,`scheduledAt`),
3152
+ KEY `ix_userCancellationDueDeviceImeiScheduledAt` (`imei`,`scheduledAt`)
3153
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3154
+
3155
+ DROP TABLE IF EXISTS `userCarrierDeactivateDevice`;
3156
+ CREATE TABLE `userCarrierDeactivateDevice` (
3157
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
3158
+ `imei` varchar(15) NOT NULL,
3159
+ `clientId` int NOT NULL,
3160
+ `subscriptionId` varchar(256) DEFAULT NULL,
3161
+ `type` varchar(50) NOT NULL,
3162
+ `scheduledAt` datetime NOT NULL,
3163
+ `executedAt` datetime DEFAULT NULL,
3164
+ `finishedAt` datetime DEFAULT NULL,
3165
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
3166
+ PRIMARY KEY (`id`),
3167
+ KEY `ixUserCarrierDeactivateDeviceImeiCreatedAt` (`imei`,`createdAt`),
3168
+ KEY `ixUserCarrierDeactivateDeviceSubscriptionId` (`subscriptionId`),
3169
+ KEY `ixUserCarrierDeactivateDeviceClientIdCreatedAt` (`clientId`,`createdAt`),
3170
+ KEY `ixUserCarrierDeactivateDeviceImeiSubscriptionId` (`imei`,`subscriptionId`)
3171
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3172
+
3173
+ DROP TABLE IF EXISTS `userCarrierReactivateDevice`;
3174
+ CREATE TABLE `userCarrierReactivateDevice` (
3175
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
3176
+ `imei` varchar(15) NOT NULL,
3177
+ `clientId` int NOT NULL,
3178
+ `subscriptionId` varchar(256) DEFAULT NULL,
3179
+ `type` varchar(50) NOT NULL,
3180
+ `scheduledAt` datetime NOT NULL,
3181
+ `executedAt` datetime DEFAULT NULL,
3182
+ `finishedAt` datetime DEFAULT NULL,
3183
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
3184
+ PRIMARY KEY (`id`),
3185
+ KEY `ixUserCarrierReactivateDeviceImeiCreatedAt` (`imei`,`createdAt`),
3186
+ KEY `ixUserCarrierReactivateDeviceSubscriptionId` (`subscriptionId`),
3187
+ KEY `ixUserCarrierReactivateDeviceClientIdCreatedAt` (`clientId`,`createdAt`),
3188
+ KEY `ixUserCarrierDeactivateDeviceImeiSubscriptionId` (`imei`,`subscriptionId`)
3189
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3190
+
3191
+ DROP TABLE IF EXISTS `userConfiguration`;
3192
+ CREATE TABLE `userConfiguration` (
3193
+ `id` int NOT NULL AUTO_INCREMENT,
3194
+ `userId` binary(16) NOT NULL,
3195
+ `isMetric` tinyint(1) NOT NULL,
3196
+ `timezone` varchar(255) DEFAULT 'EST',
3197
+ `createdAt` datetime DEFAULT NULL,
3198
+ `modifiedAt` datetime DEFAULT NULL,
3199
+ `defaultMapLayer` varchar(25) DEFAULT NULL,
3200
+ `speedUnits` varchar(10) DEFAULT NULL,
3201
+ `distanceUnits` varchar(10) DEFAULT NULL,
3202
+ `alertsNotificationsOn` tinyint(1) DEFAULT '1',
3203
+ `dataSourceTypeId` tinyint DEFAULT NULL,
3204
+ `homepage` varchar(50) DEFAULT NULL,
3205
+ `temperatureUnits` varchar(10) DEFAULT NULL,
3206
+ `addressFormat` varchar(100) DEFAULT NULL,
3207
+ `assetProfileStatusLabelsEnabled` tinyint(1) NOT NULL DEFAULT '1',
3208
+ `trackerClusteringEnabled` tinyint(1) NOT NULL DEFAULT '1',
3209
+ PRIMARY KEY (`id`),
3210
+ KEY `ixUserConfigurationUserId` (`userId`)
3211
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3212
+
3213
+ DROP TABLE IF EXISTS `userDataDeletionRequest`;
3214
+ CREATE TABLE `userDataDeletionRequest` (
3215
+ `id` int NOT NULL AUTO_INCREMENT,
3216
+ `userId` binary(16) NOT NULL,
3217
+ `clientId` int NOT NULL,
3218
+ `userSecurityRoleName` varchar(50) NOT NULL,
3219
+ `email` varchar(255) NOT NULL,
3220
+ `status` varchar(25) DEFAULT NULL,
3221
+ `createdAt` datetime DEFAULT NULL,
3222
+ `modifiedAt` datetime DEFAULT NULL,
3223
+ PRIMARY KEY (`id`),
3224
+ KEY `ixUserDataDeletionRequestUserId` (`userId`)
3225
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3226
+
3227
+ DROP TABLE IF EXISTS `userDeviceBehaviorTask`;
3228
+ CREATE TABLE `userDeviceBehaviorTask` (
3229
+ `id` binary(16) NOT NULL,
3230
+ `deviceBehaviorId` smallint NOT NULL,
3231
+ `clientId` int NOT NULL,
3232
+ `userId` binary(16) NOT NULL,
3233
+ `imei` varchar(15) NOT NULL,
3234
+ `behaviorName` varchar(50) NOT NULL,
3235
+ `behaviorParams` json DEFAULT NULL,
3236
+ `status` varchar(10) NOT NULL,
3237
+ `createdAt` datetime NOT NULL,
3238
+ `modifiedAt` datetime DEFAULT NULL,
3239
+ `extraParams` json DEFAULT NULL,
3240
+ `commandTaskId` binary(16) DEFAULT NULL,
3241
+ PRIMARY KEY (`id`),
3242
+ KEY `ixUserDeviceBehaviorTaskModifiedAt` (`modifiedAt`),
3243
+ KEY `ixUserDeviceBehaviorTaskDeviceBehaviorId` (`deviceBehaviorId`),
3244
+ KEY `ixUserDeviceBehaviorTaskClientId` (`clientId`),
3245
+ KEY `ixUserDeviceBehaviorTaskImei` (`imei`)
3246
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3247
+
3248
+ DROP TABLE IF EXISTS `userFreeOfferDevice`;
3249
+ CREATE TABLE `userFreeOfferDevice` (
3250
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
3251
+ `imei` varchar(15) NOT NULL,
3252
+ `clientId` int NOT NULL,
3253
+ `subscriptionId` varchar(256) DEFAULT NULL,
3254
+ `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
3255
+ PRIMARY KEY (`id`),
3256
+ KEY `idx_client_imei` (`clientId`,`imei`),
3257
+ KEY `idx_created_at` (`createdAt`),
3258
+ KEY `idx_subscription_id` (`subscriptionId`),
3259
+ KEY `idx_imei` (`imei`)
3260
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3261
+
3262
+ DROP TABLE IF EXISTS `userInvitation`;
3263
+ CREATE TABLE `userInvitation` (
3264
+ `id` binary(16) NOT NULL,
3265
+ `numberId` int NOT NULL AUTO_INCREMENT,
3266
+ `inviterClientId` int NOT NULL,
3267
+ `inviterUserId` binary(16) NOT NULL,
3268
+ `inviteeEmail` varchar(255) NOT NULL,
3269
+ `inviteeSecurityRoleId` tinyint NOT NULL,
3270
+ `statusId` tinyint NOT NULL,
3271
+ `createdAt` datetime NOT NULL,
3272
+ `modifiedAt` datetime NOT NULL,
3273
+ `inviteeUserId` binary(16) DEFAULT NULL,
3274
+ `trackerImeis` mediumtext,
3275
+ `trackerAccess` text,
3276
+ `minAccessDate` datetime DEFAULT NULL,
3277
+ `boundaries` text,
3278
+ `boundaryAccess` text,
3279
+ `tasksAccess` text,
3280
+ `customSecurityRoleId` int DEFAULT NULL,
3281
+ PRIMARY KEY (`id`),
3282
+ UNIQUE KEY `IDX_eed52f71523517126416cc2208` (`numberId`),
3283
+ KEY `ixUserInvtationInviteeSecurityRoleId` (`inviteeSecurityRoleId`),
3284
+ KEY `ixUserInvtationInviteUserId` (`inviterUserId`),
3285
+ KEY `ixUserInvtationInviterClientId` (`inviterClientId`),
3286
+ KEY `ixUserInvtationInviteeEmail` (`inviteeEmail`)
3287
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3288
+
3289
+ DROP TABLE IF EXISTS `userRatingRequest`;
3290
+ CREATE TABLE `userRatingRequest` (
3291
+ `id` int NOT NULL AUTO_INCREMENT,
3292
+ `userId` binary(16) NOT NULL,
3293
+ `clientId` int NOT NULL,
3294
+ `deviceManufacturer` varchar(500) NOT NULL,
3295
+ `deviceOs` varchar(50) NOT NULL,
3296
+ `deviceOsVersion` varchar(20) NOT NULL,
3297
+ `appVersion` varchar(10) NOT NULL,
3298
+ `requestDate` datetime DEFAULT NULL,
3299
+ `amazonRequestDate` datetime DEFAULT NULL,
3300
+ `deviceIdentifierKey` varchar(255) DEFAULT NULL,
3301
+ PRIMARY KEY (`id`),
3302
+ KEY `ixUserRatingRequestUserId_RequestDate` (`userId`,`requestDate`),
3303
+ KEY `ixUserRatingRequestRequestDate` (`requestDate`),
3304
+ KEY `ixUserRatingRequestClientId` (`clientId`),
3305
+ KEY `ixUserRatingRequestAmazonRequestDate` (`amazonRequestDate`)
3306
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3307
+
3308
+ DROP TABLE IF EXISTS `userRegistrationAttempt`;
3309
+ CREATE TABLE `userRegistrationAttempt` (
3310
+ `id` int NOT NULL AUTO_INCREMENT,
3311
+ `firstName` varchar(100) DEFAULT NULL,
3312
+ `lastName` varchar(100) DEFAULT NULL,
3313
+ `email` varchar(255) DEFAULT NULL,
3314
+ `phoneNumber` varchar(20) DEFAULT NULL,
3315
+ `phoneCode` varchar(10) DEFAULT NULL,
3316
+ `phoneCodeCountryId` varchar(10) DEFAULT NULL,
3317
+ `companyName` varchar(255) DEFAULT NULL,
3318
+ `street` varchar(255) DEFAULT NULL,
3319
+ `state` varchar(100) DEFAULT NULL,
3320
+ `postalCode` varchar(20) DEFAULT NULL,
3321
+ `country` varchar(100) DEFAULT NULL,
3322
+ `pin` int DEFAULT NULL,
3323
+ `imei` varchar(15) DEFAULT NULL,
3324
+ `deviceType` varchar(50) DEFAULT NULL,
3325
+ `deviceName` varchar(255) DEFAULT NULL,
3326
+ `orderId` varchar(255) DEFAULT NULL,
3327
+ `trackingReason` varchar(255) DEFAULT NULL,
3328
+ `userName` varchar(50) DEFAULT NULL,
3329
+ `plan` varchar(50) DEFAULT NULL,
3330
+ `billingFrequency` varchar(50) DEFAULT NULL,
3331
+ `planId` varchar(50) DEFAULT NULL,
3332
+ `subscriptionSource` varchar(50) DEFAULT NULL,
3333
+ `subscriptionId` varchar(50) DEFAULT NULL,
3334
+ `platform` varchar(25) DEFAULT NULL,
3335
+ `status` varchar(10) DEFAULT NULL,
3336
+ `createdAt` datetime DEFAULT NULL,
3337
+ `lastUpdatedAt` datetime DEFAULT NULL,
3338
+ `city` varchar(255) DEFAULT NULL,
3339
+ `clientId` int DEFAULT NULL,
3340
+ `countryCode` varchar(3) DEFAULT NULL,
3341
+ `tempUserId` binary(16) DEFAULT NULL,
3342
+ PRIMARY KEY (`id`),
3343
+ KEY `ixUserRegistrationAttemptTempUserId` (`tempUserId`)
3344
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3345
+
3346
+ DROP TABLE IF EXISTS `userSecurityRole`;
3347
+ CREATE TABLE `userSecurityRole` (
3348
+ `clientId` int NOT NULL,
3349
+ `userId` binary(16) NOT NULL,
3350
+ `securityRoleId` tinyint NOT NULL,
3351
+ `access` enum('full','limited') NOT NULL DEFAULT 'full',
3352
+ `boundariesAccess` enum('full','limited') NOT NULL DEFAULT 'full',
3353
+ `minAccessDate` datetime DEFAULT NULL,
3354
+ `tasksAccess` enum('full','can_complete','read_only','no_access') NOT NULL DEFAULT 'full',
3355
+ `devicesAccess` enum('full','limited') NOT NULL DEFAULT 'full',
3356
+ `customSecurityRoleId` int DEFAULT NULL,
3357
+ PRIMARY KEY (`userId`,`securityRoleId`),
3358
+ KEY `ixUserSecurityRoleClientIdAccessUserId` (`clientId`,`access`,`userId`),
3359
+ KEY `ixUserSecurityRoleSecurityRoleId` (`securityRoleId`)
3360
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3361
+
3362
+ DROP TABLE IF EXISTS `websocketConnection`;
3363
+ CREATE TABLE `websocketConnection` (
3364
+ `connectionId` varchar(36) NOT NULL,
3365
+ `clientId` int NOT NULL,
3366
+ `userId` binary(16) NOT NULL,
3367
+ `host` varchar(255) NOT NULL,
3368
+ `createdAt` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
3369
+ `subscription` json DEFAULT NULL,
3370
+ PRIMARY KEY (`connectionId`),
3371
+ KEY `ixWebsocketConnectionCreatedAt` (`createdAt`),
3372
+ KEY `ixWebsocketConnectionClientIdUserIdHost` (`clientId`,`userId`,`host`),
3373
+ KEY `ixWebsocketConnectionUserId` (`userId`)
3374
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
3375
+
3376
+ DROP VIEW IF EXISTS `user_authorized_boundary_security_view`;
3377
+ CREATE ALGORITHM=UNDEFINED VIEW `user_authorized_boundary_security_view` AS select `b`.`clientId` AS `clientId`,`usr`.`userId` AS `userId`,`b`.`id` AS `boundaryId` from (`userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) join `boundary` `b` on((`b`.`clientId` = `usr`.`clientId`))) where ((`usr`.`boundariesAccess` = 'full') and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `usr`.`clientId`) and (`ut`.`userId` = `usr`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false) union all select `b`.`clientId` AS `clientId`,`usr`.`userId` AS `userId`,`b`.`id` AS `boundaryId` from (((`entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) join `entityTag` `rt` on(((`rt`.`tagId` = `ut`.`tagId`) and (`rt`.`entityType` = 'Boundary') and (`rt`.`isSecurityGroup` = 1) and (`rt`.`clientId` = `ut`.`clientId`)))) join `boundary` `b` on(((`b`.`clientId` = `rt`.`clientId`) and (`b`.`id` = `rt`.`entityId`)))) join `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) on(((`usr`.`clientId` = `rt`.`clientId`) and (`usr`.`userId` = `ut`.`userId`)))) where ((`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1)) union all select `uab`.`clientId` AS `clientId`,`uab`.`userId` AS `userId`,`uab`.`boundaryId` AS `boundaryId` from `userAuthorizedBoundary` `uab` where (exists(select 1 from `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) where ((`usr`.`clientId` = `uab`.`clientId`) and (`usr`.`userId` = `uab`.`userId`) and (`usr`.`boundariesAccess` = 'full'))) is false and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `uab`.`clientId`) and (`ut`.`userId` = `uab`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false);
3378
+
3379
+ DROP VIEW IF EXISTS `user_authorized_boundary_security_view_v2`;
3380
+ CREATE ALGORITHM=UNDEFINED VIEW `user_authorized_boundary_security_view_v2` AS select `b`.`clientId` AS `clientId`,`usr`.`userId` AS `userId`,`b`.`id` AS `boundaryId` from (`userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) join `boundary` `b` on((`b`.`clientId` = `usr`.`clientId`))) where ((`usr`.`boundariesAccess` = 'full') and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `usr`.`clientId`) and (`ut`.`userId` = `usr`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false) union all select `b`.`clientId` AS `clientId`,`usr`.`userId` AS `userId`,`b`.`id` AS `boundaryId` from (((`entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) join `entityTag` `rt` on(((`rt`.`tagId` = `ut`.`tagId`) and (`rt`.`entityType` = 'Boundary') and (`rt`.`isSecurityGroup` = 1) and (`rt`.`clientId` = `ut`.`clientId`)))) join `boundary` `b` on(((`b`.`clientId` = `rt`.`clientId`) and (`b`.`id` = `rt`.`entityId`)))) join `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) on(((`usr`.`clientId` = `rt`.`clientId`) and (`usr`.`userId` = `ut`.`userId`)))) where ((`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1)) union all select `uab`.`clientId` AS `clientId`,`uab`.`userId` AS `userId`,`uab`.`boundaryId` AS `boundaryId` from `userAuthorizedBoundary` `uab` where (exists(select 1 from `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) where ((`usr`.`clientId` = `uab`.`clientId`) and (`usr`.`userId` = `uab`.`userId`) and (`usr`.`boundariesAccess` = 'full'))) is false and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `uab`.`clientId`) and (`ut`.`userId` = `uab`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false);
3381
+
3382
+ DROP VIEW IF EXISTS `user_authorized_device_security_view`;
3383
+ CREATE ALGORITHM=UNDEFINED VIEW `user_authorized_device_security_view` AS select `d`.`clientId` AS `clientId`,`d`.`imei` AS `imei`,`usr`.`userId` AS `userId` from (`userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) join `device` `d` on((`d`.`clientId` = `usr`.`clientId`))) where ((`usr`.`access` = 'full') and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `usr`.`clientId`) and (`ut`.`userId` = `usr`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false) union all select `d`.`clientId` AS `clientId`,`d`.`imei` AS `imei`,`usr`.`userId` AS `userId` from (((`entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) join `entityTag` `rt` USE INDEX (`ixEntityTagImeiIsSecurityGroupTagId`) on(((`rt`.`tagId` = `ut`.`tagId`) and (`rt`.`entityType` = 'Device') and (`rt`.`isSecurityGroup` = 1) and (`rt`.`clientId` = `ut`.`clientId`)))) join `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) on(((`usr`.`clientId` = `rt`.`clientId`) and (`usr`.`userId` = `ut`.`userId`)))) join `device` `d` USE INDEX (`ixDeviceClientIdImei`) on(((`d`.`clientId` = `rt`.`clientId`) and (`d`.`imei` = `rt`.`imei`)))) where ((`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1)) union all select `uad`.`clientId` AS `clientId`,`uad`.`imei` AS `imei`,`uad`.`userId` AS `userId` from `userAuthorizedDevice` `uad` where (exists(select 1 from `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) where ((`usr`.`clientId` = `uad`.`clientId`) and (`usr`.`userId` = `uad`.`userId`) and (`usr`.`access` = 'full'))) is false and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `uad`.`clientId`) and (`ut`.`userId` = `uad`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false);
3384
+
3385
+ DROP VIEW IF EXISTS `user_authorized_device_security_view_v2`;
3386
+ CREATE ALGORITHM=UNDEFINED VIEW `user_authorized_device_security_view_v2` AS select `d`.`clientId` AS `clientId`,`d`.`imei` AS `imei`,`usr`.`userId` AS `userId` from (`userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) join `device` `d` on((`d`.`clientId` = `usr`.`clientId`))) where ((`usr`.`access` = 'full') and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `usr`.`clientId`) and (`ut`.`userId` = `usr`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false) union all select `d`.`clientId` AS `clientId`,`d`.`imei` AS `imei`,`usr`.`userId` AS `userId` from (((`entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) join `entityTag` `rt` USE INDEX (`ixEntityTagImeiIsSecurityGroupTagId`) on(((`rt`.`tagId` = `ut`.`tagId`) and (`rt`.`entityType` = 'Device') and (`rt`.`isSecurityGroup` = 1) and (`rt`.`clientId` = `ut`.`clientId`)))) join `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) on(((`usr`.`clientId` = `rt`.`clientId`) and (`usr`.`userId` = `ut`.`userId`)))) join `device` `d` USE INDEX (`ixDeviceClientIdImei`) on(((`d`.`clientId` = `rt`.`clientId`) and (`d`.`imei` = `rt`.`imei`)))) where ((`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1)) union all select `uad`.`clientId` AS `clientId`,`uad`.`imei` AS `imei`,`uad`.`userId` AS `userId` from `userAuthorizedDevice` `uad` where (exists(select 1 from `userSecurityRole` `usr` USE INDEX (`ixUserSecurityRoleClientIdAccessUserId`) where ((`usr`.`clientId` = `uad`.`clientId`) and (`usr`.`userId` = `uad`.`userId`) and (`usr`.`access` = 'full'))) is false and exists(select 1 from `entityTag` `ut` USE INDEX (`ixEntityTagClientIdUserIdEntityTypeIsSecurityGroupTagId`) where ((`ut`.`clientId` = `uad`.`clientId`) and (`ut`.`userId` = `uad`.`userId`) and (`ut`.`entityType` = 'User') and (`ut`.`isSecurityGroup` = 1))) is false);
3387
+
3388
+ SET FOREIGN_KEY_CHECKS = 1;