feat: prisma schema, groups API, deploy workflow
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../node_modules/.prisma/client"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
username String @unique
|
||||
password String
|
||||
role String @default("user")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
profile Profile?
|
||||
canvases Canvas[]
|
||||
groupMembers GroupMember[]
|
||||
activities Activity[]
|
||||
followers Follow[] @relation("following")
|
||||
following Follow[] @relation("follower")
|
||||
}
|
||||
|
||||
model Profile {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
displayName String
|
||||
bio String @default("")
|
||||
avatar String @default("")
|
||||
canvasCount Int @default(0)
|
||||
followerCount Int @default(0)
|
||||
followingCount Int @default(0)
|
||||
joinedAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model Canvas {
|
||||
id String @id
|
||||
name String
|
||||
ownerId String
|
||||
groupId String?
|
||||
isPublic Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
nodes CanvasNode[]
|
||||
edges CanvasEdge[]
|
||||
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
group Group? @relation(fields: [groupId], references: [id], onDelete: SetNull)
|
||||
}
|
||||
|
||||
model CanvasNode {
|
||||
id String @id
|
||||
canvasId String
|
||||
type String
|
||||
x Float
|
||||
y Float
|
||||
width Float
|
||||
height Float
|
||||
text String?
|
||||
file String?
|
||||
state String?
|
||||
label String?
|
||||
assignedTo String?
|
||||
alarm String?
|
||||
scriptId String?
|
||||
prompt String?
|
||||
url String?
|
||||
method String?
|
||||
repo String?
|
||||
branch String?
|
||||
styleJson String?
|
||||
|
||||
canvas Canvas @relation(fields: [canvasId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model CanvasEdge {
|
||||
id String @id
|
||||
canvasId String
|
||||
fromNode String
|
||||
fromSide String
|
||||
toNode String
|
||||
toSide String
|
||||
|
||||
canvas Canvas @relation(fields: [canvasId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model Group {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String @default("")
|
||||
isPublic Boolean @default(true)
|
||||
ownerId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
members GroupMember[]
|
||||
canvases Canvas[]
|
||||
}
|
||||
|
||||
model GroupMember {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
groupId String
|
||||
role String @default("member")
|
||||
joinedAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([userId, groupId])
|
||||
}
|
||||
|
||||
model Activity {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
action String
|
||||
targetId String
|
||||
targetType String
|
||||
timestamp DateTime @default(now())
|
||||
metadata String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model Follow {
|
||||
id String @id @default(cuid())
|
||||
followerId String
|
||||
followingId String
|
||||
since DateTime @default(now())
|
||||
|
||||
follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade)
|
||||
following User @relation("following", fields: [followingId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([followerId, followingId])
|
||||
}
|
||||
Reference in New Issue
Block a user