我的应用程序中有一些资产会不时以异步方式更新。
我要在这里使用的例子是Vehicles
. 有两个表:
Vehicles
:保存有关车辆本身的信息VehicleUpdates
:保存有关该车辆发生的所有更新的信息。表结构的相关部分是:
CREATE TABLE `Vehicles` (
`id` varchar(50) NOT NULL,
`organizationId` varchar(50) NOT NULL,
`plate` char(7) NOT NULL,
`vehicleInfo` json DEFAULT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `unq_Vehicles_orgId_plate_idx` (`organizationId`,`plate`) USING BTREE,
KEY `Vehicles_createdAt_idx` (`createdAt`),
);
CREATE TABLE `VehicleUpdates` (
`id` varchar(50) NOT NULL,
`organizationId` varchar(50) NOT NULL,
`vehiclePlate` char(7) NOT NULL,
`status` varchar(15) NOT NULL, …
Run Code Online (Sandbox Code Playgroud)