CAR_GPS_REACT/prisma/schema.prisma

58 lines
1.3 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// 1. Define the database connection
datasource db {
provider = "postgresql" // Or "mysql" if you decide to switch
url = env("DATABASE_URL")
}
// 2. Define the Prisma Client generator
generator client {
provider = "prisma-client-js"
}
// 3. Define your data models
model Device {
id String @id @default(uuid())
imei String @unique
name String?
telemetry Telemetry[]
commands Command[]
}
model Telemetry {
id String @id @default(uuid())
deviceId String
device Device @relation(fields: [deviceId], references: [id])
recordedAt DateTime @default(now())
lat Float
lng Float
altitude Float?
speed Float?
heading Float?
accuracy Float?
battery Float?
isCarOn Boolean?
raw Json?
}
model Command {
id Int @id @default(autoincrement())
deviceId String
device Device @relation(fields: [deviceId], references: [id])
type String
payload Json
createdAt DateTime @default(now())
}
model CommandTemplate {
id Int @id @default(autoincrement())
name String
type String
payload Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}