2025-01-14 21:37:31 +00:00
|
|
|
// This is your Prisma schema file,
|
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
|
|
|
|
generator client {
|
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource db {
|
2025-01-23 18:23:46 +00:00
|
|
|
provider = "postgresql"
|
2025-01-14 21:37:31 +00:00
|
|
|
url = env("DATABASE_URL")
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 23:44:42 +00:00
|
|
|
enum RepoIndexingStatus {
|
|
|
|
|
NEW
|
|
|
|
|
IN_INDEX_QUEUE
|
|
|
|
|
INDEXING
|
|
|
|
|
INDEXED
|
|
|
|
|
FAILED
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-24 21:16:08 +00:00
|
|
|
enum ConnectionSyncStatus {
|
2025-01-21 19:50:35 +00:00
|
|
|
SYNC_NEEDED
|
|
|
|
|
IN_SYNC_QUEUE
|
|
|
|
|
SYNCING
|
|
|
|
|
SYNCED
|
|
|
|
|
FAILED
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-14 21:37:31 +00:00
|
|
|
model Repo {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
name String
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
indexedAt DateTime?
|
|
|
|
|
isFork Boolean
|
|
|
|
|
isArchived Boolean
|
|
|
|
|
metadata Json
|
|
|
|
|
cloneUrl String
|
2025-01-24 21:16:08 +00:00
|
|
|
connections RepoToConnection[]
|
2025-01-14 21:37:31 +00:00
|
|
|
|
2025-01-15 23:44:42 +00:00
|
|
|
repoIndexingStatus RepoIndexingStatus @default(NEW)
|
|
|
|
|
|
2025-01-14 21:37:31 +00:00
|
|
|
// The id of the repo in the external service
|
|
|
|
|
external_id String
|
|
|
|
|
// The type of the external service (e.g., github, gitlab, etc.)
|
|
|
|
|
external_codeHostType String
|
|
|
|
|
// The base url of the external service (e.g., https://github.com)
|
|
|
|
|
external_codeHostUrl String
|
|
|
|
|
|
2025-01-24 21:16:08 +00:00
|
|
|
org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
|
|
|
|
orgId Int
|
2025-01-21 22:50:16 +00:00
|
|
|
|
2025-01-14 21:37:31 +00:00
|
|
|
@@unique([external_id, external_codeHostUrl])
|
|
|
|
|
}
|
2025-01-16 23:24:13 +00:00
|
|
|
|
2025-01-24 21:16:08 +00:00
|
|
|
model Connection {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
config Json
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
2025-01-21 19:50:35 +00:00
|
|
|
syncedAt DateTime?
|
2025-01-24 21:16:08 +00:00
|
|
|
repos RepoToConnection[]
|
|
|
|
|
|
|
|
|
|
syncStatus ConnectionSyncStatus @default(SYNC_NEEDED)
|
|
|
|
|
|
|
|
|
|
// The organization that owns this connection
|
|
|
|
|
org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
|
|
|
|
orgId Int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model RepoToConnection {
|
|
|
|
|
addedAt DateTime @default(now())
|
|
|
|
|
|
|
|
|
|
connection Connection @relation(fields: [connectionId], references: [id], onDelete: Cascade)
|
|
|
|
|
connectionId Int
|
2025-01-21 19:50:35 +00:00
|
|
|
|
2025-01-24 21:16:08 +00:00
|
|
|
repo Repo @relation(fields: [repoId], references: [id], onDelete: Cascade)
|
|
|
|
|
repoId Int
|
2025-01-21 19:50:35 +00:00
|
|
|
|
2025-01-24 21:16:08 +00:00
|
|
|
@@id([connectionId, repoId])
|
2025-01-21 19:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-17 00:18:16 +00:00
|
|
|
model Org {
|
2025-01-24 21:16:08 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
name String
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
members UserToOrg[]
|
|
|
|
|
connections Connection[]
|
|
|
|
|
repos Repo[]
|
2025-01-27 22:07:07 +00:00
|
|
|
secrets Secret[]
|
2025-01-21 22:50:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum OrgRole {
|
|
|
|
|
OWNER
|
|
|
|
|
MEMBER
|
2025-01-17 00:18:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model UserToOrg {
|
|
|
|
|
joinedAt DateTime @default(now())
|
|
|
|
|
|
|
|
|
|
/// The linked organization
|
|
|
|
|
org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
|
|
|
|
orgId Int
|
|
|
|
|
|
|
|
|
|
/// The linked user
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
userId String
|
|
|
|
|
|
2025-01-21 22:50:16 +00:00
|
|
|
role OrgRole @default(MEMBER)
|
|
|
|
|
|
2025-01-17 00:18:16 +00:00
|
|
|
@@id([orgId, userId])
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-27 22:07:07 +00:00
|
|
|
model Secret {
|
|
|
|
|
orgId Int
|
|
|
|
|
key String
|
|
|
|
|
encryptedValue String
|
|
|
|
|
iv String
|
|
|
|
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
|
|
|
|
org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
|
|
@@id([orgId, key])
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-16 23:24:13 +00:00
|
|
|
// @see : https://authjs.dev/concepts/database-models#user
|
|
|
|
|
model User {
|
2025-01-21 22:50:16 +00:00
|
|
|
id String @id @default(cuid())
|
2025-01-16 23:24:13 +00:00
|
|
|
name String?
|
2025-01-21 22:50:16 +00:00
|
|
|
email String? @unique
|
2025-01-16 23:24:13 +00:00
|
|
|
emailVerified DateTime?
|
|
|
|
|
image String?
|
|
|
|
|
accounts Account[]
|
2025-01-17 00:18:16 +00:00
|
|
|
orgs UserToOrg[]
|
2025-01-21 22:50:16 +00:00
|
|
|
activeOrgId Int?
|
2025-01-16 23:24:13 +00:00
|
|
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @see : https://authjs.dev/concepts/database-models#account
|
|
|
|
|
model Account {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
userId String
|
|
|
|
|
type String
|
|
|
|
|
provider String
|
|
|
|
|
providerAccountId String
|
|
|
|
|
refresh_token String?
|
|
|
|
|
access_token String?
|
|
|
|
|
expires_at Int?
|
|
|
|
|
token_type String?
|
|
|
|
|
scope String?
|
|
|
|
|
id_token String?
|
|
|
|
|
session_state String?
|
|
|
|
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
|
|
@@unique([provider, providerAccountId])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @see : https://authjs.dev/concepts/database-models#verificationtoken
|
|
|
|
|
model VerificationToken {
|
|
|
|
|
identifier String
|
|
|
|
|
token String
|
|
|
|
|
expires DateTime
|
|
|
|
|
|
|
|
|
|
@@unique([identifier, token])
|
|
|
|
|
}
|