Rename User relation wifiDevices
This commit is contained in:
parent
cb6ba1999f
commit
b1594643c2
|
@ -0,0 +1,44 @@
|
|||
# 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())
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
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
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"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\""
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
# Prisma Migrate lockfile v1
|
||||
|
||||
20201110194349-init
|
||||
20201119134248-add-controller-to-wifi-device
|
||||
20201119134248-add-controller-to-wifi-device
|
||||
20201120191035-fix-relations
|
|
@ -66,9 +66,9 @@ model User {
|
|||
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 {
|
||||
|
|
|
@ -108,9 +108,9 @@ const Query = {
|
|||
|
||||
const usersWithWifiDevices = await prisma.user.findMany({
|
||||
where: {
|
||||
WifiDevice: { some: { lastSeen: { not: null } } }
|
||||
wifiDevices: { some: { lastSeen: { not: null } } }
|
||||
},
|
||||
include: { WifiDevice: { orderBy: [{ lastSeen: 'desc' }] } }
|
||||
include: { wifiDevices: { orderBy: [{ lastSeen: 'desc' }] } }
|
||||
})
|
||||
|
||||
search = search.toLowerCase()
|
||||
|
@ -120,7 +120,7 @@ const Query = {
|
|||
user =>
|
||||
user.displayName.toLowerCase().includes(search) ||
|
||||
user.sAMAccountName.toLowerCase().includes(search) ||
|
||||
user.WifiDevice.some(device =>
|
||||
user.wifiDevices.some(device =>
|
||||
device.apName.toLowerCase().includes(search)
|
||||
)
|
||||
)
|
||||
|
@ -130,7 +130,7 @@ const Query = {
|
|||
displayName: user.displayName,
|
||||
thumbnailPhoto: user.thumbnailPhoto
|
||||
},
|
||||
wifiDevices: user.WifiDevice
|
||||
wifiDevices: user.wifiDevices
|
||||
}))
|
||||
|
||||
const sortedUserPresences = userPresences.sort((a, b) =>
|
||||
|
|
|
@ -44,7 +44,7 @@ const User = {
|
|||
sAMAccountName: _.sAMAccountName
|
||||
}
|
||||
})
|
||||
.WifiDevice()
|
||||
.wifiDevices()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user