diff --git a/server/package.json b/server/package.json index f604812..984f5b7 100755 --- a/server/package.json +++ b/server/package.json @@ -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": { diff --git a/server/prisma/migrations/20201217174326_v2_5_0/migration.sql b/server/prisma/migrations/20201217174326_v2_5_0/migration.sql new file mode 100644 index 0000000..bffaf73 --- /dev/null +++ b/server/prisma/migrations/20201217174326_v2_5_0/migration.sql @@ -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") +); diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index 41dd9db..32edbd6 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -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 +} diff --git a/web/package.json b/web/package.json index 248d300..fb5c043 100755 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "ifms-pti", - "version": "2.4.0", + "version": "2.5.0", "private": true, "scripts": { "serve": "vue-cli-service serve",