ifms-pti/server/prisma/migrations/20201106194210-init/README.md
2020-11-06 16:34:32 -04:00

5.6 KiB

Migration 20201106194210-init

This migration has been generated by Douglas Barone at 11/6/2020, 3:42:10 PM. You can check out the state of the schema after the migration.

Database Steps

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" text   ,
"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   ,
"hostname" text   ,
"firstSeen" text   ,
"lastSeen" text   ,
"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   NOT NULL ,
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 CASCADE ON UPDATE CASCADE

Changes

diff --git schema.prisma schema.prisma
migration ..20201106194210-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           String?
+  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[]
+}
+
+model WifiDevice {
+  id        Int      @id @default(autoincrement())
+  oui       String?
+  mac       String?  @unique
+  hostname  String?
+  firstSeen String?
+  lastSeen  String?
+  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])
+}
+
+enum Status {
+  ONLINE
+  OFFLINE
+}