2024-03-13 03:46:50 +13:00
|
|
|
// This is your Prisma schema file,
|
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
|
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
|
|
|
|
|
|
generator client {
|
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
|
provider = "mysql"
|
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Node {
|
2024-03-31 23:47:56 +13:00
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
node_id BigInt @unique
|
2024-03-13 03:46:50 +13:00
|
|
|
long_name String
|
|
|
|
|
short_name String
|
|
|
|
|
hardware_model Int
|
|
|
|
|
role Int
|
2024-03-31 23:47:56 +13:00
|
|
|
is_licensed Boolean?
|
2025-08-06 19:48:26 +02:00
|
|
|
public_key String?
|
|
|
|
|
is_unmessagable Boolean?
|
2024-03-13 03:46:50 +13:00
|
|
|
|
2024-03-31 23:59:55 +13:00
|
|
|
firmware_version String?
|
|
|
|
|
region Int?
|
|
|
|
|
modem_preset Int?
|
|
|
|
|
has_default_channel Boolean?
|
|
|
|
|
position_precision Int?
|
|
|
|
|
num_online_local_nodes Int?
|
|
|
|
|
|
2024-03-23 23:47:37 +13:00
|
|
|
latitude Int?
|
|
|
|
|
longitude Int?
|
|
|
|
|
altitude Int?
|
|
|
|
|
position_updated_at DateTime?
|
2024-03-13 03:46:50 +13:00
|
|
|
|
2024-03-13 04:14:30 +13:00
|
|
|
battery_level Int?
|
|
|
|
|
voltage Decimal?
|
|
|
|
|
channel_utilization Decimal?
|
|
|
|
|
air_util_tx Decimal?
|
2024-04-16 16:32:26 +12:00
|
|
|
uptime_seconds BigInt?
|
2024-03-13 04:14:30 +13:00
|
|
|
|
2024-06-07 00:12:53 +12:00
|
|
|
temperature Decimal?
|
|
|
|
|
relative_humidity Decimal?
|
|
|
|
|
barometric_pressure Decimal?
|
|
|
|
|
|
2024-03-23 22:56:03 +13:00
|
|
|
neighbour_broadcast_interval_secs Int?
|
|
|
|
|
neighbours Json?
|
2024-03-23 23:34:02 +13:00
|
|
|
neighbours_updated_at DateTime?
|
2024-03-23 22:56:03 +13:00
|
|
|
|
2024-08-28 22:53:04 +12:00
|
|
|
// this column tracks when an mqtt gateway node uplinked a packet
|
2024-03-31 18:05:31 +13:00
|
|
|
mqtt_connection_state_updated_at DateTime?
|
|
|
|
|
|
2025-04-15 17:27:15 +02:00
|
|
|
ok_to_mqtt Boolean?
|
2025-08-10 10:41:39 +02:00
|
|
|
is_backbone Boolean?
|
|
|
|
|
max_hops Int?
|
2025-04-15 17:27:15 +02:00
|
|
|
|
2025-08-13 21:50:50 +02:00
|
|
|
channel_id String?
|
|
|
|
|
|
2024-03-13 03:46:50 +13:00
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
2024-11-21 12:58:05 +13:00
|
|
|
@@index(position_updated_at)
|
2024-03-13 15:13:06 +13:00
|
|
|
@@index(node_id)
|
2024-03-13 03:46:50 +13:00
|
|
|
@@map("nodes")
|
|
|
|
|
}
|
2024-03-13 13:54:32 +13:00
|
|
|
|
2024-03-13 15:05:51 +13:00
|
|
|
model MapReport {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
node_id BigInt
|
|
|
|
|
long_name String
|
|
|
|
|
short_name String
|
|
|
|
|
role Int
|
|
|
|
|
hardware_model Int
|
|
|
|
|
firmware_version String
|
|
|
|
|
|
|
|
|
|
region Int?
|
|
|
|
|
modem_preset Int?
|
|
|
|
|
has_default_channel Boolean?
|
|
|
|
|
latitude Int?
|
|
|
|
|
longitude Int?
|
|
|
|
|
altitude Int?
|
|
|
|
|
position_precision Int?
|
|
|
|
|
num_online_local_nodes Int?
|
|
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
|
|
|
|
@@index(node_id)
|
|
|
|
|
@@map("map_reports")
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-13 13:54:32 +13:00
|
|
|
model NeighbourInfo {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
node_id BigInt
|
|
|
|
|
node_broadcast_interval_secs Int
|
|
|
|
|
neighbours Json
|
|
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
2024-03-13 15:13:06 +13:00
|
|
|
@@index(node_id)
|
2024-03-13 13:54:32 +13:00
|
|
|
@@map("neighbour_infos")
|
|
|
|
|
}
|
2024-03-13 14:18:47 +13:00
|
|
|
|
2024-03-14 00:55:27 +13:00
|
|
|
model DeviceMetric {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
node_id BigInt
|
|
|
|
|
|
|
|
|
|
battery_level Int?
|
|
|
|
|
voltage Decimal?
|
|
|
|
|
channel_utilization Decimal?
|
|
|
|
|
air_util_tx Decimal?
|
|
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
|
|
|
|
@@index(node_id)
|
|
|
|
|
@@map("device_metrics")
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-06 23:40:58 +12:00
|
|
|
model EnvironmentMetric {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
node_id BigInt
|
|
|
|
|
packet_id BigInt?
|
|
|
|
|
|
|
|
|
|
temperature Decimal?
|
|
|
|
|
relative_humidity Decimal?
|
|
|
|
|
barometric_pressure Decimal?
|
|
|
|
|
gas_resistance Decimal?
|
|
|
|
|
voltage Decimal?
|
|
|
|
|
current Decimal?
|
|
|
|
|
iaq Int?
|
2024-12-17 16:09:55 +13:00
|
|
|
wind_direction Int?
|
|
|
|
|
wind_speed Decimal?
|
|
|
|
|
wind_gust Decimal?
|
|
|
|
|
wind_lull Decimal?
|
2024-06-06 23:40:58 +12:00
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
|
|
|
|
@@index(node_id)
|
|
|
|
|
@@index(packet_id)
|
|
|
|
|
@@map("environment_metrics")
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-06 23:53:23 +12:00
|
|
|
model PowerMetric {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
node_id BigInt
|
|
|
|
|
packet_id BigInt?
|
|
|
|
|
|
|
|
|
|
ch1_voltage Decimal?
|
|
|
|
|
ch1_current Decimal?
|
|
|
|
|
ch2_voltage Decimal?
|
|
|
|
|
ch2_current Decimal?
|
|
|
|
|
ch3_voltage Decimal?
|
|
|
|
|
ch3_current Decimal?
|
|
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
|
|
|
|
@@index(node_id)
|
|
|
|
|
@@index(packet_id)
|
|
|
|
|
@@map("power_metrics")
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-23 20:44:52 +12:00
|
|
|
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")
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-16 18:32:19 +13:00
|
|
|
model ServiceEnvelope {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
mqtt_topic String
|
|
|
|
|
channel_id String
|
|
|
|
|
gateway_id BigInt?
|
|
|
|
|
to BigInt
|
|
|
|
|
from BigInt
|
2025-04-15 17:55:04 +02:00
|
|
|
portnum Int?
|
2025-04-15 20:49:27 +02:00
|
|
|
packet_id BigInt?
|
2024-03-16 18:32:19 +13:00
|
|
|
protobuf Bytes
|
|
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
2024-03-16 19:10:39 +13:00
|
|
|
@@index(gateway_id)
|
2025-04-15 20:49:27 +02:00
|
|
|
@@index(packet_id)
|
2024-03-16 18:32:19 +13:00
|
|
|
@@map("service_envelopes")
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-14 23:28:49 +13:00
|
|
|
model TextMessage {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
to BigInt
|
|
|
|
|
from BigInt
|
|
|
|
|
channel Int
|
|
|
|
|
packet_id BigInt
|
|
|
|
|
channel_id String
|
|
|
|
|
gateway_id BigInt?
|
|
|
|
|
|
|
|
|
|
text String
|
|
|
|
|
|
|
|
|
|
rx_time BigInt?
|
|
|
|
|
rx_snr Decimal?
|
|
|
|
|
rx_rssi Int?
|
|
|
|
|
hop_limit Int?
|
2025-09-29 20:46:23 +02:00
|
|
|
ok_to_mqtt Boolean?
|
2024-03-14 23:28:49 +13:00
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
|
|
|
|
@@index(to)
|
|
|
|
|
@@index(from)
|
|
|
|
|
@@index(packet_id)
|
|
|
|
|
@@index(gateway_id)
|
|
|
|
|
@@map("text_messages")
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-13 14:18:47 +13:00
|
|
|
model TraceRoute {
|
2024-04-16 14:15:25 +12:00
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
to BigInt
|
|
|
|
|
from BigInt
|
|
|
|
|
want_response Boolean
|
|
|
|
|
route Json
|
2024-09-08 13:00:49 +12:00
|
|
|
snr_towards Json?
|
|
|
|
|
route_back Json?
|
|
|
|
|
snr_back Json?
|
2024-03-13 14:18:47 +13:00
|
|
|
|
2024-03-19 02:27:23 +13:00
|
|
|
channel Int?
|
|
|
|
|
packet_id BigInt?
|
|
|
|
|
channel_id String?
|
|
|
|
|
gateway_id BigInt?
|
|
|
|
|
|
2024-03-13 14:18:47 +13:00
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
2024-04-16 14:15:25 +12:00
|
|
|
@@index(to)
|
|
|
|
|
@@index(from)
|
2024-03-13 14:18:47 +13:00
|
|
|
@@map("traceroutes")
|
|
|
|
|
}
|
2024-03-15 16:11:51 +13:00
|
|
|
|
|
|
|
|
model Waypoint {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
from BigInt
|
|
|
|
|
to BigInt
|
|
|
|
|
waypoint_id BigInt
|
|
|
|
|
latitude Int
|
|
|
|
|
longitude Int
|
|
|
|
|
expire BigInt?
|
|
|
|
|
locked_to BigInt?
|
|
|
|
|
name String?
|
|
|
|
|
description String?
|
|
|
|
|
icon Int?
|
|
|
|
|
|
|
|
|
|
channel Int
|
|
|
|
|
packet_id BigInt
|
|
|
|
|
channel_id String
|
|
|
|
|
gateway_id BigInt?
|
|
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
|
|
|
|
@@index(to)
|
|
|
|
|
@@index(from)
|
|
|
|
|
@@index(waypoint_id)
|
|
|
|
|
@@index(packet_id)
|
|
|
|
|
@@index(gateway_id)
|
|
|
|
|
@@map("waypoints")
|
|
|
|
|
}
|
2025-04-26 15:58:56 +02:00
|
|
|
|
2025-04-26 22:09:31 +02:00
|
|
|
model NameHistory {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
node_id BigInt
|
|
|
|
|
long_name String
|
|
|
|
|
short_name String
|
|
|
|
|
|
|
|
|
|
created_at DateTime @default(now())
|
|
|
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index(node_id)
|
|
|
|
|
@@index(long_name)
|
|
|
|
|
|
|
|
|
|
@@index(created_at)
|
|
|
|
|
@@index(updated_at)
|
|
|
|
|
@@map("name_history")
|
|
|
|
|
|
|
|
|
|
// We only want to keep track of unique name and node_id combinations
|
|
|
|
|
@@unique([node_id, long_name, short_name])
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-26 15:58:56 +02:00
|
|
|
model BatteryStats {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
recorded_at DateTime? @default(now())
|
|
|
|
|
avg_battery_level Decimal? @db.Decimal(5, 2)
|
|
|
|
|
|
|
|
|
|
@@index([recorded_at])
|
|
|
|
|
@@map("battery_stats")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model ChannelUtilizationStats {
|
|
|
|
|
id BigInt @id @default(autoincrement())
|
|
|
|
|
recorded_at DateTime? @default(now())
|
|
|
|
|
avg_channel_utilization Decimal?
|
2025-09-25 20:17:42 +02:00
|
|
|
channel_id String?
|
2025-04-26 15:58:56 +02:00
|
|
|
|
2025-09-25 20:17:42 +02:00
|
|
|
@@index([channel_id])
|
2025-04-26 15:58:56 +02:00
|
|
|
@@index([recorded_at])
|
|
|
|
|
@@map("channel_utilization_stats")
|
|
|
|
|
}
|