collect position history in database

This commit is contained in:
liamcottle
2024-05-23 20:44:52 +12:00
parent 112094b01f
commit 538023f7b6
3 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,22 @@
-- CreateTable
CREATE TABLE `positions` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`node_id` BIGINT NOT NULL,
`to` BIGINT NOT NULL,
`from` BIGINT NOT NULL,
`channel` INTEGER NULL,
`packet_id` BIGINT NULL,
`channel_id` VARCHAR(191) NULL,
`gateway_id` BIGINT NULL,
`latitude` INTEGER NULL,
`longitude` INTEGER NULL,
`altitude` INTEGER NULL,
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
INDEX `positions_created_at_idx`(`created_at`),
INDEX `positions_updated_at_idx`(`updated_at`),
INDEX `positions_node_id_idx`(`node_id`),
INDEX `positions_packet_id_idx`(`packet_id`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -116,6 +116,31 @@ model DeviceMetric {
@@map("device_metrics")
}
model Position {
id BigInt @id @default(autoincrement())
node_id BigInt
to BigInt
from BigInt
channel Int?
packet_id BigInt?
channel_id String?
gateway_id BigInt?
latitude Int?
longitude Int?
altitude Int?
created_at DateTime @default(now())
updated_at DateTime @default(now()) @updatedAt
@@index(created_at)
@@index(updated_at)
@@index(node_id)
@@index(packet_id)
@@map("positions")
}
model ServiceEnvelope {
id BigInt @id @default(autoincrement())
mqtt_topic String