v2.5.0 DB schema

This commit is contained in:
Douglas Barone 2020-12-17 13:47:43 -04:00
parent b4d0f7af13
commit ea5e698264
4 changed files with 70 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ifms-pti-svr",
"version": "2.4.0",
"version": "2.5.0",
"description": "Servidor GraphQL para concentrar as informações do IFMS",
"main": "src/index.js",
"scripts": {

View File

@ -0,0 +1,37 @@
-- CreateEnum
CREATE TYPE "public"."LogLevel" AS ENUM ('LOW', 'INFO', 'SUCCESS', 'WARNING', 'ERROR');
-- AlterEnum
ALTER TYPE "Status" ADD VALUE 'RECENT';
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "lastLogin" SET DEFAULT CURRENT_TIMESTAMP,
ALTER COLUMN "lastLoginPrior" SET DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "WifiDevice" ALTER COLUMN "firstSeen" SET DEFAULT CURRENT_TIMESTAMP;
-- CreateTable
CREATE TABLE "Log" (
"id" SERIAL,
"timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"level" "LogLevel" NOT NULL DEFAULT E'LOW',
"tags" JSONB,
"message" TEXT NOT NULL,
"data" JSONB,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Statistic" (
"id" SERIAL,
"timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"onlineUsers" INTEGER NOT NULL,
"offlineUsers" INTEGER NOT NULL,
"totalUsers" INTEGER NOT NULL,
"totalWifiDevices" INTEGER NOT NULL,
"onlineWifiDevices" INTEGER NOT NULL,
PRIMARY KEY ("id")
);

View File

@ -22,8 +22,8 @@ model ResetToken {
model User {
id Int @id @default(autoincrement())
lastLogin DateTime?
lastLoginPrior DateTime?
lastLogin DateTime? @default(now())
lastLoginPrior DateTime? @default(now())
roles Json?
groups Json?
createdAt DateTime @default(now())
@ -76,7 +76,7 @@ model WifiDevice {
oui String?
mac String @unique
hostname String?
firstSeen DateTime?
firstSeen DateTime? @default(now())
lastSeen DateTime?
essid String?
ip String?
@ -92,5 +92,33 @@ model WifiDevice {
enum Status {
ONLINE
RECENT
OFFLINE
}
model Log {
id Int @id @default(autoincrement())
timestamp DateTime @default(now())
level LogLevel @default(LOW)
tags Json?
message String
data Json?
}
enum LogLevel {
LOW
INFO
SUCCESS
WARNING
ERROR
}
model Statistic {
id Int @id @default(autoincrement())
timestamp DateTime @default(now())
onlineUsers Int
offlineUsers Int
totalUsers Int
totalWifiDevices Int
onlineWifiDevices Int
}

View File

@ -1,6 +1,6 @@
{
"name": "ifms-pti",
"version": "2.4.0",
"version": "2.5.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",