diff --git a/server/package.json b/server/package.json index ba8c5d3..0eb1c5a 100755 --- a/server/package.json +++ b/server/package.json @@ -7,7 +7,7 @@ "start": "node --tls-min-v1.0 dist/index.js", "dev": "nodemon --tls-min-v1.0 --ext js,graphql src/index.js --exec 'babel-node'", "babel-node": "babel-node --presets='@babel/preset-env'", - "prisma-deploy": "prisma migrate up --experimental", + "prisma-deploy": "prisma migrate deploy --preview-feature", "prisma-generate": "prisma generate", "build": "babel src --out-dir dist --copy-files" }, diff --git a/server/prisma/migrations/20201110194349-init/README.md b/server/prisma/migrations/20201110194349-init/README.md deleted file mode 100644 index 9a0f75f..0000000 --- a/server/prisma/migrations/20201110194349-init/README.md +++ /dev/null @@ -1,206 +0,0 @@ -# Migration `20201110194349-init` - -This migration has been generated by Douglas Barone at 11/10/2020, 3:43:49 PM. -You can check out the [state of the schema](./schema.prisma) after the migration. - -## Database Steps - -```sql -CREATE TABLE "public"."ResetToken" ( -"id" SERIAL, -"token" text NOT NULL , -"expiration" timestamp(3) NOT NULL , -"usedAt" timestamp(3) , -"createdAt" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, -"updatedAt" timestamp(3) NOT NULL , -"userId" integer NOT NULL , -"creatorId" integer NOT NULL , -PRIMARY KEY ("id") -) - -CREATE TABLE "public"."User" ( -"id" SERIAL, -"lastLogin" timestamp(3) , -"lastLoginPrior" timestamp(3) , -"roles" jsonb , -"groups" jsonb , -"createdAt" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, -"updatedAt" timestamp(3) NOT NULL , -"accountExpires" text , -"badPasswordTime" text , -"badPwdCount" text , -"cn" text , -"department" text , -"description" text , -"displayName" text , -"distinguishedName" text , -"dn" text , -"extensionAttribute1" text , -"extensionAttribute10" text , -"extensionAttribute2" text , -"extensionAttribute6" text , -"extensionAttribute7" text , -"givenName" text , -"homeDirectory" text , -"homeDrive" text , -"lastLogoff" text , -"lastLogon" text , -"lastLogonTimestamp" text , -"lockoutTime" text , -"logonCount" text , -"mail" text , -"name" text , -"objectCategory" text , -"objectGUID" text , -"objectSid" text , -"primaryGroupID" text , -"pwdLastSet" timestamp(3) , -"sAMAccountName" text NOT NULL , -"sAMAccountType" text , -"sn" text , -"thumbnailPhoto" text , -"title" text , -"userAccountControl" text , -"userPrincipalName" text , -"whenChanged" text , -"whenCreated" text , -PRIMARY KEY ("id") -) - -CREATE TABLE "public"."WifiDevice" ( -"id" SERIAL, -"oui" text , -"mac" text NOT NULL , -"hostname" text , -"firstSeen" timestamp(3) , -"lastSeen" timestamp(3) , -"essid" text , -"ip" text , -"uptime" text , -"apName" text , -"status" "Status" , -"createdAt" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, -"updatedAt" timestamp(3) NOT NULL , -"userId" integer , -PRIMARY KEY ("id") -) - -CREATE UNIQUE INDEX "ResetToken.token_unique" ON "public"."ResetToken"("token") - -CREATE UNIQUE INDEX "User.sAMAccountName_unique" ON "public"."User"("sAMAccountName") - -CREATE UNIQUE INDEX "WifiDevice.mac_unique" ON "public"."WifiDevice"("mac") - -ALTER TABLE "public"."ResetToken" ADD FOREIGN KEY("userId")REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE "public"."ResetToken" ADD FOREIGN KEY("creatorId")REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE "public"."WifiDevice" ADD FOREIGN KEY("userId")REFERENCES "public"."User"("id") ON DELETE SET NULL ON UPDATE CASCADE -``` - -## Changes - -```diff -diff --git schema.prisma schema.prisma -migration ..20201110194349-init ---- datamodel.dml -+++ datamodel.dml -@@ -1,0 +1,95 @@ -+generator client { -+ provider = "prisma-client-js" -+} -+ -+datasource db { -+ provider = "postgresql" -+ url = "***" -+} -+ -+model ResetToken { -+ id Int @id @default(autoincrement()) -+ token String @unique -+ expiration DateTime -+ usedAt DateTime? -+ createdAt DateTime @default(now()) -+ updatedAt DateTime @updatedAt -+ user User @relation(fields: [userId], references: [id], name: "resettoken_to_user") -+ userId Int -+ creator User @relation(fields: [creatorId], references: [id], name: "resettoken_to_creator") -+ creatorId Int -+} -+ -+model User { -+ id Int @id @default(autoincrement()) -+ lastLogin DateTime? -+ lastLoginPrior DateTime? -+ roles Json? -+ groups Json? -+ createdAt DateTime @default(now()) -+ updatedAt DateTime @updatedAt -+ accountExpires String? -+ badPasswordTime String? -+ badPwdCount String? -+ cn String? -+ department String? -+ description String? -+ displayName String? -+ distinguishedName String? -+ dn String? -+ extensionAttribute1 String? -+ extensionAttribute10 String? -+ extensionAttribute2 String? -+ extensionAttribute6 String? -+ extensionAttribute7 String? -+ givenName String? -+ homeDirectory String? -+ homeDrive String? -+ lastLogoff String? -+ lastLogon String? -+ lastLogonTimestamp String? -+ lockoutTime String? -+ logonCount String? -+ mail String? -+ name String? -+ objectCategory String? -+ objectGUID String? -+ objectSid String? -+ primaryGroupID String? -+ pwdLastSet DateTime? -+ sAMAccountName String @unique -+ sAMAccountType String? -+ sn String? -+ thumbnailPhoto String? -+ title String? -+ userAccountControl String? -+ userPrincipalName String? -+ whenChanged String? -+ whenCreated String? -+ createdTokens ResetToken[] @relation("resettoken_to_user") -+ tokens ResetToken[] @relation("resettoken_to_creator") -+ WifiDevice WifiDevice[] @relation("wifidevice_to_user") -+} -+ -+model WifiDevice { -+ id Int @id @default(autoincrement()) -+ oui String? -+ mac String @unique -+ hostname String? -+ firstSeen DateTime? -+ lastSeen DateTime? -+ essid String? -+ ip String? -+ uptime String? -+ apName String? -+ status Status? -+ createdAt DateTime @default(now()) -+ updatedAt DateTime @updatedAt -+ userId Int? -+ user User? @relation(fields: [userId], references: [id], name: "wifidevice_to_user") -+} -+ -+enum Status { -+ ONLINE -+ OFFLINE -+} -``` - - diff --git a/server/prisma/migrations/20201110194349-init/schema.prisma b/server/prisma/migrations/20201110194349-init/schema.prisma deleted file mode 100644 index 470b64a..0000000 --- a/server/prisma/migrations/20201110194349-init/schema.prisma +++ /dev/null @@ -1,95 +0,0 @@ -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = "***" -} - -model ResetToken { - id Int @id @default(autoincrement()) - token String @unique - expiration DateTime - usedAt DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id], name: "resettoken_to_user") - userId Int - creator User @relation(fields: [creatorId], references: [id], name: "resettoken_to_creator") - creatorId Int -} - -model User { - id Int @id @default(autoincrement()) - lastLogin DateTime? - lastLoginPrior DateTime? - roles Json? - groups Json? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - accountExpires String? - badPasswordTime String? - badPwdCount String? - cn String? - department String? - description String? - displayName String? - distinguishedName String? - dn String? - extensionAttribute1 String? - extensionAttribute10 String? - extensionAttribute2 String? - extensionAttribute6 String? - extensionAttribute7 String? - givenName String? - homeDirectory String? - homeDrive String? - lastLogoff String? - lastLogon String? - lastLogonTimestamp String? - lockoutTime String? - logonCount String? - mail String? - name String? - objectCategory String? - objectGUID String? - objectSid String? - primaryGroupID String? - pwdLastSet DateTime? - sAMAccountName String @unique - sAMAccountType String? - sn String? - thumbnailPhoto String? - title String? - userAccountControl String? - userPrincipalName String? - whenChanged String? - whenCreated String? - createdTokens ResetToken[] @relation("resettoken_to_user") - tokens ResetToken[] @relation("resettoken_to_creator") - WifiDevice WifiDevice[] @relation("wifidevice_to_user") -} - -model WifiDevice { - id Int @id @default(autoincrement()) - oui String? - mac String @unique - hostname String? - firstSeen DateTime? - lastSeen DateTime? - essid String? - ip String? - uptime String? - apName String? - status Status? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - userId Int? - user User? @relation(fields: [userId], references: [id], name: "wifidevice_to_user") -} - -enum Status { - ONLINE - OFFLINE -} diff --git a/server/prisma/migrations/20201110194349-init/steps.json b/server/prisma/migrations/20201110194349-init/steps.json deleted file mode 100644 index e36845f..0000000 --- a/server/prisma/migrations/20201110194349-init/steps.json +++ /dev/null @@ -1,1041 +0,0 @@ -{ - "version": "0.3.14-fixed", - "steps": [ - { - "tag": "CreateEnum", - "enum": "Status", - "values": [ - "ONLINE", - "OFFLINE" - ] - }, - { - "tag": "CreateSource", - "source": "db" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Source", - "source": "db" - }, - "argument": "provider", - "value": "\"postgresql\"" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Source", - "source": "db" - }, - "argument": "url", - "value": "\"***\"" - }, - { - "tag": "CreateModel", - "model": "ResetToken" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "token", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "token" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "expiration", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "usedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "updatedAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "user", - "type": "User", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "user" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "user" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[userId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "user" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "user" - }, - "directive": "relation" - }, - "argument": "name", - "value": "\"resettoken_to_user\"" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "userId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "creator", - "type": "User", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "creator" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "creator" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[creatorId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "creator" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "ResetToken", - "field": "creator" - }, - "directive": "relation" - }, - "argument": "name", - "value": "\"resettoken_to_creator\"" - }, - { - "tag": "CreateField", - "model": "ResetToken", - "field": "creatorId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateModel", - "model": "User" - }, - { - "tag": "CreateField", - "model": "User", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateField", - "model": "User", - "field": "lastLogin", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "lastLoginPrior", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "roles", - "type": "Json", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "groups", - "type": "Json", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateField", - "model": "User", - "field": "updatedAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "User", - "field": "accountExpires", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "badPasswordTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "badPwdCount", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "cn", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "department", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "description", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "displayName", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "distinguishedName", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "dn", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "extensionAttribute1", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "extensionAttribute10", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "extensionAttribute2", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "extensionAttribute6", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "extensionAttribute7", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "givenName", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "homeDirectory", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "homeDrive", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "lastLogoff", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "lastLogon", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "lastLogonTimestamp", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "lockoutTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "logonCount", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "mail", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "objectCategory", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "objectGUID", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "objectSid", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "primaryGroupID", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "pwdLastSet", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "sAMAccountName", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "sAMAccountName" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "User", - "field": "sAMAccountType", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "sn", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "thumbnailPhoto", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "title", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "userAccountControl", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "userPrincipalName", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "whenChanged", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "whenCreated", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "createdTokens", - "type": "ResetToken", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "createdTokens" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "createdTokens" - }, - "directive": "relation" - }, - "argument": "", - "value": "\"resettoken_to_user\"" - }, - { - "tag": "CreateField", - "model": "User", - "field": "tokens", - "type": "ResetToken", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "tokens" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "tokens" - }, - "directive": "relation" - }, - "argument": "", - "value": "\"resettoken_to_creator\"" - }, - { - "tag": "CreateField", - "model": "User", - "field": "WifiDevice", - "type": "WifiDevice", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "WifiDevice" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "WifiDevice" - }, - "directive": "relation" - }, - "argument": "", - "value": "\"wifidevice_to_user\"" - }, - { - "tag": "CreateModel", - "model": "WifiDevice" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "oui", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "mac", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "mac" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "hostname", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "firstSeen", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "lastSeen", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "essid", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "ip", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "uptime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "apName", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "status", - "type": "Status", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "updatedAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "userId", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "user", - "type": "User", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "user" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "user" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[userId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "user" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "user" - }, - "directive": "relation" - }, - "argument": "name", - "value": "\"wifidevice_to_user\"" - } - ] -} \ No newline at end of file diff --git a/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/README.md b/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/README.md deleted file mode 100644 index 16a5e2f..0000000 --- a/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Migration `20201119134248-add-controller-to-wifi-device` - -This migration has been generated by Douglas Barone at 11/19/2020, 9:42:48 AM. -You can check out the [state of the schema](./schema.prisma) after the migration. - -## Database Steps - -```sql -ALTER TABLE "WifiDevice" ADD COLUMN "controller" TEXT NOT NULL DEFAULT E'unknown' -``` - -## Changes - -```diff -diff --git schema.prisma schema.prisma -migration 20201110194349-init..20201119134248-add-controller-to-wifi-device ---- datamodel.dml -+++ datamodel.dml -@@ -3,9 +3,9 @@ - } - datasource db { - provider = "postgresql" -- url = "***" -+ url = "***" - } - model ResetToken { - id Int @id @default(autoincrement()) -@@ -71,23 +71,24 @@ - WifiDevice WifiDevice[] @relation("wifidevice_to_user") - } - model WifiDevice { -- id Int @id @default(autoincrement()) -- oui String? -- mac String @unique -- hostname String? -- firstSeen DateTime? -- lastSeen DateTime? -- essid String? -- ip String? -- uptime String? -- apName String? -- status Status? -- createdAt DateTime @default(now()) -- updatedAt DateTime @updatedAt -- userId Int? -- user User? @relation(fields: [userId], references: [id], name: "wifidevice_to_user") -+ id Int @id @default(autoincrement()) -+ mac String @unique -+ controller String @default("unknown") -+ createdAt DateTime @default(now()) -+ updatedAt DateTime @updatedAt -+ oui String? -+ hostname String? -+ firstSeen DateTime? -+ lastSeen DateTime? -+ essid String? -+ ip String? -+ uptime String? -+ apName String? -+ status Status? -+ userId Int? -+ user User? @relation(fields: [userId], references: [id], name: "wifidevice_to_user") - } - enum Status { - ONLINE -``` - - diff --git a/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/schema.prisma b/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/schema.prisma deleted file mode 100644 index eb30da2..0000000 --- a/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/schema.prisma +++ /dev/null @@ -1,96 +0,0 @@ -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = "***" -} - -model ResetToken { - id Int @id @default(autoincrement()) - token String @unique - expiration DateTime - usedAt DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id], name: "resettoken_to_user") - userId Int - creator User @relation(fields: [creatorId], references: [id], name: "resettoken_to_creator") - creatorId Int -} - -model User { - id Int @id @default(autoincrement()) - lastLogin DateTime? - lastLoginPrior DateTime? - roles Json? - groups Json? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - accountExpires String? - badPasswordTime String? - badPwdCount String? - cn String? - department String? - description String? - displayName String? - distinguishedName String? - dn String? - extensionAttribute1 String? - extensionAttribute10 String? - extensionAttribute2 String? - extensionAttribute6 String? - extensionAttribute7 String? - givenName String? - homeDirectory String? - homeDrive String? - lastLogoff String? - lastLogon String? - lastLogonTimestamp String? - lockoutTime String? - logonCount String? - mail String? - name String? - objectCategory String? - objectGUID String? - objectSid String? - primaryGroupID String? - pwdLastSet DateTime? - sAMAccountName String @unique - sAMAccountType String? - sn String? - thumbnailPhoto String? - title String? - userAccountControl String? - userPrincipalName String? - whenChanged String? - whenCreated String? - createdTokens ResetToken[] @relation("resettoken_to_user") - tokens ResetToken[] @relation("resettoken_to_creator") - WifiDevice WifiDevice[] @relation("wifidevice_to_user") -} - -model WifiDevice { - id Int @id @default(autoincrement()) - mac String @unique - controller String @default("unknown") - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - oui String? - hostname String? - firstSeen DateTime? - lastSeen DateTime? - essid String? - ip String? - uptime String? - apName String? - status Status? - userId Int? - user User? @relation(fields: [userId], references: [id], name: "wifidevice_to_user") -} - -enum Status { - ONLINE - OFFLINE -} diff --git a/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/steps.json b/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/steps.json deleted file mode 100644 index 6bdae71..0000000 --- a/server/prisma/migrations/20201119134248-add-controller-to-wifi-device/steps.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "version": "0.3.14-fixed", - "steps": [ - { - "tag": "CreateField", - "model": "WifiDevice", - "field": "controller", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "controller" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "WifiDevice", - "field": "controller" - }, - "directive": "default" - }, - "argument": "", - "value": "\"unknown\"" - } - ] -} \ No newline at end of file diff --git a/server/prisma/migrations/20201120191035-fix-relations/README.md b/server/prisma/migrations/20201120191035-fix-relations/README.md deleted file mode 100644 index a39fee7..0000000 --- a/server/prisma/migrations/20201120191035-fix-relations/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Migration `20201120191035-fix-relations` - -This migration has been generated by Douglas Barone at 11/20/2020, 3:10:35 PM. -You can check out the [state of the schema](./schema.prisma) after the migration. - -## Database Steps - -```sql - -``` - -## Changes - -```diff -diff --git schema.prisma schema.prisma -migration 20201119134248-add-controller-to-wifi-device..20201120191035-fix-relations ---- datamodel.dml -+++ datamodel.dml -@@ -3,9 +3,9 @@ - } - datasource db { - provider = "postgresql" -- url = "***" -+ url = "***" - } - model ResetToken { - id Int @id @default(autoincrement()) -@@ -65,11 +65,11 @@ - userAccountControl String? - userPrincipalName String? - whenChanged String? - whenCreated String? -- createdTokens ResetToken[] @relation("resettoken_to_user") -- tokens ResetToken[] @relation("resettoken_to_creator") -- WifiDevice WifiDevice[] @relation("wifidevice_to_user") -+ createdTokens ResetToken[] @relation("resettoken_to_creator") -+ tokens ResetToken[] @relation("resettoken_to_user") -+ wifiDevices WifiDevice[] @relation("wifidevice_to_user") - } - model WifiDevice { - id Int @id @default(autoincrement()) -``` - - diff --git a/server/prisma/migrations/20201120191035-fix-relations/schema.prisma b/server/prisma/migrations/20201120191035-fix-relations/schema.prisma deleted file mode 100644 index a74610f..0000000 --- a/server/prisma/migrations/20201120191035-fix-relations/schema.prisma +++ /dev/null @@ -1,96 +0,0 @@ -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = "***" -} - -model ResetToken { - id Int @id @default(autoincrement()) - token String @unique - expiration DateTime - usedAt DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id], name: "resettoken_to_user") - userId Int - creator User @relation(fields: [creatorId], references: [id], name: "resettoken_to_creator") - creatorId Int -} - -model User { - id Int @id @default(autoincrement()) - lastLogin DateTime? - lastLoginPrior DateTime? - roles Json? - groups Json? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - accountExpires String? - badPasswordTime String? - badPwdCount String? - cn String? - department String? - description String? - displayName String? - distinguishedName String? - dn String? - extensionAttribute1 String? - extensionAttribute10 String? - extensionAttribute2 String? - extensionAttribute6 String? - extensionAttribute7 String? - givenName String? - homeDirectory String? - homeDrive String? - lastLogoff String? - lastLogon String? - lastLogonTimestamp String? - lockoutTime String? - logonCount String? - mail String? - name String? - objectCategory String? - objectGUID String? - objectSid String? - primaryGroupID String? - pwdLastSet DateTime? - sAMAccountName String @unique - sAMAccountType String? - sn String? - thumbnailPhoto String? - title String? - userAccountControl String? - userPrincipalName String? - whenChanged String? - whenCreated String? - createdTokens ResetToken[] @relation("resettoken_to_creator") - tokens ResetToken[] @relation("resettoken_to_user") - wifiDevices WifiDevice[] @relation("wifidevice_to_user") -} - -model WifiDevice { - id Int @id @default(autoincrement()) - mac String @unique - controller String @default("unknown") - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - oui String? - hostname String? - firstSeen DateTime? - lastSeen DateTime? - essid String? - ip String? - uptime String? - apName String? - status Status? - userId Int? - user User? @relation(fields: [userId], references: [id], name: "wifidevice_to_user") -} - -enum Status { - ONLINE - OFFLINE -} diff --git a/server/prisma/migrations/20201120191035-fix-relations/steps.json b/server/prisma/migrations/20201120191035-fix-relations/steps.json deleted file mode 100644 index c4e3bbb..0000000 --- a/server/prisma/migrations/20201120191035-fix-relations/steps.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "version": "0.3.14-fixed", - "steps": [ - { - "tag": "CreateField", - "model": "User", - "field": "wifiDevices", - "type": "WifiDevice", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "wifiDevices" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "wifiDevices" - }, - "directive": "relation" - }, - "argument": "", - "value": "\"wifidevice_to_user\"" - }, - { - "tag": "DeleteField", - "model": "User", - "field": "WifiDevice" - }, - { - "tag": "UpdateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "createdTokens" - }, - "directive": "relation" - }, - "argument": "", - "newValue": "\"resettoken_to_creator\"" - }, - { - "tag": "UpdateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "tokens" - }, - "directive": "relation" - }, - "argument": "", - "newValue": "\"resettoken_to_user\"" - } - ] -} \ No newline at end of file diff --git a/server/prisma/migrations/20201215195739_init/migration.sql b/server/prisma/migrations/20201215195739_init/migration.sql new file mode 100644 index 0000000..1545cb0 --- /dev/null +++ b/server/prisma/migrations/20201215195739_init/migration.sql @@ -0,0 +1,106 @@ +-- CreateEnum +CREATE TYPE "public"."Status" AS ENUM ('ONLINE', 'OFFLINE'); + +-- CreateTable +CREATE TABLE "ResetToken" ( +"id" SERIAL, + "token" TEXT NOT NULL, + "expiration" TIMESTAMP(3) NOT NULL, + "usedAt" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "userId" INTEGER NOT NULL, + "creatorId" INTEGER NOT NULL, + + PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "User" ( +"id" SERIAL, + "lastLogin" TIMESTAMP(3), + "lastLoginPrior" TIMESTAMP(3), + "roles" JSONB, + "groups" JSONB, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "accountExpires" TEXT, + "badPasswordTime" TEXT, + "badPwdCount" TEXT, + "cn" TEXT, + "department" TEXT, + "description" TEXT, + "displayName" TEXT, + "distinguishedName" TEXT, + "dn" TEXT, + "extensionAttribute1" TEXT, + "extensionAttribute10" TEXT, + "extensionAttribute2" TEXT, + "extensionAttribute6" TEXT, + "extensionAttribute7" TEXT, + "givenName" TEXT, + "homeDirectory" TEXT, + "homeDrive" TEXT, + "lastLogoff" TEXT, + "lastLogon" TEXT, + "lastLogonTimestamp" TEXT, + "lockoutTime" TEXT, + "logonCount" TEXT, + "mail" TEXT, + "name" TEXT, + "objectCategory" TEXT, + "objectGUID" TEXT, + "objectSid" TEXT, + "primaryGroupID" TEXT, + "pwdLastSet" TIMESTAMP(3), + "sAMAccountName" TEXT NOT NULL, + "sAMAccountType" TEXT, + "sn" TEXT, + "thumbnailPhoto" TEXT, + "title" TEXT, + "userAccountControl" TEXT, + "userPrincipalName" TEXT, + "whenChanged" TEXT, + "whenCreated" TEXT, + + PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "WifiDevice" ( +"id" SERIAL, + "oui" TEXT, + "mac" TEXT NOT NULL, + "hostname" TEXT, + "firstSeen" TIMESTAMP(3), + "lastSeen" TIMESTAMP(3), + "essid" TEXT, + "ip" TEXT, + "uptime" TEXT, + "apName" TEXT, + "status" "Status", + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "userId" INTEGER, + "controller" TEXT NOT NULL DEFAULT E'unknown', + + PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "ResetToken.token_unique" ON "ResetToken"("token"); + +-- CreateIndex +CREATE UNIQUE INDEX "User.sAMAccountName_unique" ON "User"("sAMAccountName"); + +-- CreateIndex +CREATE UNIQUE INDEX "WifiDevice.mac_unique" ON "WifiDevice"("mac"); + +-- AddForeignKey +ALTER TABLE "ResetToken" ADD FOREIGN KEY("creatorId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResetToken" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "WifiDevice" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/server/prisma/migrations/migrate.lock b/server/prisma/migrations/migrate.lock deleted file mode 100644 index 760ab79..0000000 --- a/server/prisma/migrations/migrate.lock +++ /dev/null @@ -1,5 +0,0 @@ -# Prisma Migrate lockfile v1 - -20201110194349-init -20201119134248-add-controller-to-wifi-device -20201120191035-fix-relations \ No newline at end of file diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index be82567..41dd9db 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -14,10 +14,10 @@ model ResetToken { usedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id], name: "resettoken_to_user") userId Int - creator User @relation(fields: [creatorId], references: [id], name: "resettoken_to_creator") creatorId Int + creator User @relation("resettoken_to_creator", fields: [creatorId], references: [id]) + user User @relation("resettoken_to_user", fields: [userId], references: [id]) } model User { @@ -73,11 +73,8 @@ model User { model WifiDevice { id Int @id @default(autoincrement()) - mac String @unique - controller String @default("unknown") - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt oui String? + mac String @unique hostname String? firstSeen DateTime? lastSeen DateTime? @@ -86,8 +83,11 @@ model WifiDevice { uptime String? apName String? status Status? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt userId Int? - user User? @relation(fields: [userId], references: [id], name: "wifidevice_to_user") + controller String @default("unknown") + user User? @relation("wifidevice_to_user", fields: [userId], references: [id]) } enum Status { diff --git a/server/src/classes/User.js b/server/src/classes/User.js index fad5f20..6fc2bc0 100755 --- a/server/src/classes/User.js +++ b/server/src/classes/User.js @@ -236,11 +236,6 @@ class User { ) return oldUserData - await prisma.user.update({ - data: { updatedAt: now }, - where: { sAMAccountName: username } - }) - const adUser = await ad.findUser(username) if (!adUser) throw new Error('Usuário não encontrado') @@ -250,6 +245,7 @@ class User { const user = { ...adUser, + updatedAt: now, roles, groups }