implement database and mqtt client to cache node info
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `nodes` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`node_id` BIGINT NOT NULL,
|
||||
`long_name` VARCHAR(191) NOT NULL,
|
||||
`short_name` VARCHAR(191) NOT NULL,
|
||||
`hardware_model` INTEGER NOT NULL,
|
||||
`is_licensed` BOOLEAN NOT NULL,
|
||||
`role` INTEGER NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
UNIQUE INDEX `nodes_node_id_key`(`node_id`),
|
||||
INDEX `nodes_created_at_idx`(`created_at`),
|
||||
INDEX `nodes_updated_at_idx`(`updated_at`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
@ -0,0 +1,4 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `nodes` ADD COLUMN `altitude` INTEGER NULL,
|
||||
ADD COLUMN `latitude` INTEGER NULL,
|
||||
ADD COLUMN `longitude` INTEGER NULL;
|
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "mysql"
|
35
prisma/schema.prisma
Normal file
35
prisma/schema.prisma
Normal file
@ -0,0 +1,35 @@
|
||||
// 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 {
|
||||
id BigInt @id @default(autoincrement())
|
||||
node_id BigInt @unique
|
||||
long_name String
|
||||
short_name String
|
||||
hardware_model Int
|
||||
is_licensed Boolean
|
||||
role Int
|
||||
|
||||
latitude Int?
|
||||
longitude Int?
|
||||
altitude Int?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
|
||||
@@index(created_at)
|
||||
@@index(updated_at)
|
||||
@@map("nodes")
|
||||
}
|
Reference in New Issue
Block a user