mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 18:18:27 +00:00
fix: added more cascading tables
This commit is contained in:
parent
af56d7016e
commit
6f1037e8e1
@ -25,7 +25,7 @@ model Activity {
|
|||||||
|
|
||||||
rejectionReason String?
|
rejectionReason String?
|
||||||
|
|
||||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String
|
workspaceId String
|
||||||
|
|
||||||
WebhookDeliveryLog WebhookDeliveryLog[]
|
WebhookDeliveryLog WebhookDeliveryLog[]
|
||||||
@ -55,10 +55,10 @@ model Conversation {
|
|||||||
unread Boolean @default(false)
|
unread Boolean @default(false)
|
||||||
|
|
||||||
title String?
|
title String?
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String
|
userId String
|
||||||
|
|
||||||
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String?
|
workspaceId String?
|
||||||
|
|
||||||
status String @default("pending") // Can be "pending", "running", "completed", "failed", "need_attention"
|
status String @default("pending") // Can be "pending", "running", "completed", "failed", "need_attention"
|
||||||
@ -102,7 +102,7 @@ model ConversationHistory {
|
|||||||
context Json?
|
context Json?
|
||||||
|
|
||||||
thoughts Json?
|
thoughts Json?
|
||||||
user User? @relation(fields: [userId], references: [id])
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String?
|
userId String?
|
||||||
|
|
||||||
conversation Conversation @relation(fields: [conversationId], references: [id])
|
conversation Conversation @relation(fields: [conversationId], references: [id])
|
||||||
@ -122,7 +122,7 @@ model IngestionQueue {
|
|||||||
type String?
|
type String?
|
||||||
|
|
||||||
workspaceId String
|
workspaceId String
|
||||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
activity Activity? @relation(fields: [activityId], references: [id])
|
activity Activity? @relation(fields: [activityId], references: [id])
|
||||||
activityId String?
|
activityId String?
|
||||||
@ -148,10 +148,10 @@ model IngestionRule {
|
|||||||
source String // Source/integration this rule applies to (mandatory)
|
source String // Source/integration this rule applies to (mandatory)
|
||||||
isActive Boolean @default(true) // Enable/disable rule (mandatory)
|
isActive Boolean @default(true) // Enable/disable rule (mandatory)
|
||||||
|
|
||||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String
|
workspaceId String
|
||||||
|
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String
|
userId String
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,11 +166,11 @@ model IntegrationAccount {
|
|||||||
settings Json?
|
settings Json?
|
||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
|
|
||||||
integratedBy User @relation(references: [id], fields: [integratedById])
|
integratedBy User @relation(references: [id], fields: [integratedById], onDelete: Cascade)
|
||||||
integratedById String
|
integratedById String
|
||||||
integrationDefinition IntegrationDefinitionV2 @relation(references: [id], fields: [integrationDefinitionId])
|
integrationDefinition IntegrationDefinitionV2 @relation(references: [id], fields: [integrationDefinitionId])
|
||||||
integrationDefinitionId String
|
integrationDefinitionId String
|
||||||
workspace Workspace @relation(references: [id], fields: [workspaceId])
|
workspace Workspace @relation(references: [id], fields: [workspaceId], onDelete: Cascade)
|
||||||
workspaceId String
|
workspaceId String
|
||||||
Activity Activity[]
|
Activity Activity[]
|
||||||
oauthIntegrationGrants OAuthIntegrationGrant[]
|
oauthIntegrationGrants OAuthIntegrationGrant[]
|
||||||
@ -193,7 +193,7 @@ model IntegrationDefinitionV2 {
|
|||||||
version String?
|
version String?
|
||||||
url String?
|
url String?
|
||||||
|
|
||||||
workspace Workspace? @relation(references: [id], fields: [workspaceId])
|
workspace Workspace? @relation(references: [id], fields: [workspaceId], onDelete: Cascade)
|
||||||
workspaceId String?
|
workspaceId String?
|
||||||
|
|
||||||
IntegrationAccount IntegrationAccount[]
|
IntegrationAccount IntegrationAccount[]
|
||||||
@ -213,7 +213,7 @@ model MCPSession {
|
|||||||
source String
|
source String
|
||||||
integrations String[]
|
integrations String[]
|
||||||
|
|
||||||
workspace Workspace? @relation(references: [id], fields: [workspaceId])
|
workspace Workspace? @relation(references: [id], fields: [workspaceId], onDelete: Cascade)
|
||||||
workspaceId String?
|
workspaceId String?
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
@ -304,7 +304,7 @@ model OAuthClient {
|
|||||||
workspaceId String?
|
workspaceId String?
|
||||||
|
|
||||||
// Created by user (for audit trail)
|
// Created by user (for audit trail)
|
||||||
createdBy User? @relation(fields: [createdById], references: [id])
|
createdBy User? @relation(fields: [createdById], references: [id], onDelete: SetNull)
|
||||||
createdById String?
|
createdById String?
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
@ -330,7 +330,7 @@ model OAuthClientInstallation {
|
|||||||
workspaceId String
|
workspaceId String
|
||||||
|
|
||||||
// Installation metadata
|
// Installation metadata
|
||||||
installedBy User @relation(fields: [installedById], references: [id])
|
installedBy User @relation(fields: [installedById], references: [id], onDelete: Cascade)
|
||||||
installedById String
|
installedById String
|
||||||
installedAt DateTime @default(now())
|
installedAt DateTime @default(now())
|
||||||
uninstalledAt DateTime?
|
uninstalledAt DateTime?
|
||||||
@ -410,7 +410,7 @@ model PersonalAccessToken {
|
|||||||
/// This is used to find the token in the database
|
/// This is used to find the token in the database
|
||||||
hashedToken String @unique
|
hashedToken String @unique
|
||||||
|
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String
|
userId String
|
||||||
|
|
||||||
revokedAt DateTime?
|
revokedAt DateTime?
|
||||||
@ -454,13 +454,13 @@ model RecallLog {
|
|||||||
responseTimeMs Int? // Response time in milliseconds
|
responseTimeMs Int? // Response time in milliseconds
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String
|
userId String
|
||||||
|
|
||||||
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String?
|
workspaceId String?
|
||||||
|
|
||||||
conversation Conversation? @relation(fields: [conversationId], references: [id])
|
conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
||||||
conversationId String?
|
conversationId String?
|
||||||
|
|
||||||
// Metadata for additional tracking data
|
// Metadata for additional tracking data
|
||||||
@ -485,7 +485,7 @@ model Space {
|
|||||||
contextCountAtLastTrigger Int? // Context count when pattern was last triggered
|
contextCountAtLastTrigger Int? // Context count when pattern was last triggered
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String
|
workspaceId String
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
@ -544,7 +544,7 @@ model User {
|
|||||||
metadata Json @default("{}")
|
metadata Json @default("{}")
|
||||||
|
|
||||||
personalAccessTokens PersonalAccessToken[]
|
personalAccessTokens PersonalAccessToken[]
|
||||||
InvitationCode InvitationCode? @relation(fields: [invitationCodeId], references: [id])
|
InvitationCode InvitationCode? @relation(fields: [invitationCodeId], references: [id], onDelete: Cascade)
|
||||||
invitationCodeId String?
|
invitationCodeId String?
|
||||||
Workspace Workspace?
|
Workspace Workspace?
|
||||||
IntegrationAccount IntegrationAccount[]
|
IntegrationAccount IntegrationAccount[]
|
||||||
@ -584,7 +584,7 @@ model UserUsage {
|
|||||||
searchCreditsUsed Int @default(0)
|
searchCreditsUsed Int @default(0)
|
||||||
chatCreditsUsed Int @default(0)
|
chatCreditsUsed Int @default(0)
|
||||||
|
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String @unique
|
userId String @unique
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ model WebhookConfiguration {
|
|||||||
eventTypes String[] // List of event types this webhook is interested in, e.g. ["activity.created"]
|
eventTypes String[] // List of event types this webhook is interested in, e.g. ["activity.created"]
|
||||||
user User? @relation(fields: [userId], references: [id])
|
user User? @relation(fields: [userId], references: [id])
|
||||||
userId String?
|
userId String?
|
||||||
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String?
|
workspaceId String?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
@ -606,10 +606,10 @@ model WebhookConfiguration {
|
|||||||
|
|
||||||
model WebhookDeliveryLog {
|
model WebhookDeliveryLog {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
webhookConfiguration WebhookConfiguration @relation(fields: [webhookConfigurationId], references: [id])
|
webhookConfiguration WebhookConfiguration @relation(fields: [webhookConfigurationId], references: [id], onDelete: Cascade)
|
||||||
webhookConfigurationId String
|
webhookConfigurationId String
|
||||||
|
|
||||||
activity Activity? @relation(fields: [activityId], references: [id])
|
activity Activity? @relation(fields: [activityId], references: [id], onDelete: Cascade)
|
||||||
activityId String?
|
activityId String?
|
||||||
|
|
||||||
status WebhookDeliveryStatus
|
status WebhookDeliveryStatus
|
||||||
@ -652,7 +652,7 @@ model Subscription {
|
|||||||
overageAmount Float @default(0)
|
overageAmount Float @default(0)
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String @unique
|
workspaceId String @unique
|
||||||
BillingHistory BillingHistory[]
|
BillingHistory BillingHistory[]
|
||||||
}
|
}
|
||||||
@ -680,7 +680,7 @@ model BillingHistory {
|
|||||||
stripePaymentStatus String?
|
stripePaymentStatus String?
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
subscription Subscription @relation(fields: [subscriptionId], references: [id])
|
subscription Subscription @relation(fields: [subscriptionId], references: [id], onDelete: Cascade)
|
||||||
subscriptionId String
|
subscriptionId String
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,7 +697,7 @@ model Workspace {
|
|||||||
integrations String[]
|
integrations String[]
|
||||||
|
|
||||||
userId String? @unique
|
userId String? @unique
|
||||||
user User? @relation(fields: [userId], references: [id])
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
IngestionQueue IngestionQueue[]
|
IngestionQueue IngestionQueue[]
|
||||||
IntegrationAccount IntegrationAccount[]
|
IntegrationAccount IntegrationAccount[]
|
||||||
IntegrationDefinitionV2 IntegrationDefinitionV2[]
|
IntegrationDefinitionV2 IntegrationDefinitionV2[]
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "BillingHistory" DROP CONSTRAINT "BillingHistory_subscriptionId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "PersonalAccessToken" DROP CONSTRAINT "PersonalAccessToken_userId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "RecallLog" DROP CONSTRAINT "RecallLog_conversationId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "User" DROP CONSTRAINT "User_invitationCodeId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "WebhookDeliveryLog" DROP CONSTRAINT "WebhookDeliveryLog_activityId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "WebhookDeliveryLog" DROP CONSTRAINT "WebhookDeliveryLog_webhookConfigurationId_fkey";
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "PersonalAccessToken" ADD CONSTRAINT "PersonalAccessToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "RecallLog" ADD CONSTRAINT "RecallLog_conversationId_fkey" FOREIGN KEY ("conversationId") REFERENCES "Conversation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "User" ADD CONSTRAINT "User_invitationCodeId_fkey" FOREIGN KEY ("invitationCodeId") REFERENCES "InvitationCode"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "WebhookDeliveryLog" ADD CONSTRAINT "WebhookDeliveryLog_webhookConfigurationId_fkey" FOREIGN KEY ("webhookConfigurationId") REFERENCES "WebhookConfiguration"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "WebhookDeliveryLog" ADD CONSTRAINT "WebhookDeliveryLog_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "Activity"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "BillingHistory" ADD CONSTRAINT "BillingHistory_subscriptionId_fkey" FOREIGN KEY ("subscriptionId") REFERENCES "Subscription"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@ -410,7 +410,7 @@ model PersonalAccessToken {
|
|||||||
/// This is used to find the token in the database
|
/// This is used to find the token in the database
|
||||||
hashedToken String @unique
|
hashedToken String @unique
|
||||||
|
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String
|
userId String
|
||||||
|
|
||||||
revokedAt DateTime?
|
revokedAt DateTime?
|
||||||
@ -460,7 +460,7 @@ model RecallLog {
|
|||||||
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String?
|
workspaceId String?
|
||||||
|
|
||||||
conversation Conversation? @relation(fields: [conversationId], references: [id])
|
conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
||||||
conversationId String?
|
conversationId String?
|
||||||
|
|
||||||
// Metadata for additional tracking data
|
// Metadata for additional tracking data
|
||||||
@ -488,9 +488,9 @@ model Space {
|
|||||||
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||||
workspaceId String
|
workspaceId String
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
SpacePattern SpacePattern[]
|
SpacePattern SpacePattern[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model SpacePattern {
|
model SpacePattern {
|
||||||
@ -544,7 +544,7 @@ model User {
|
|||||||
metadata Json @default("{}")
|
metadata Json @default("{}")
|
||||||
|
|
||||||
personalAccessTokens PersonalAccessToken[]
|
personalAccessTokens PersonalAccessToken[]
|
||||||
InvitationCode InvitationCode? @relation(fields: [invitationCodeId], references: [id])
|
InvitationCode InvitationCode? @relation(fields: [invitationCodeId], references: [id], onDelete: Cascade)
|
||||||
invitationCodeId String?
|
invitationCodeId String?
|
||||||
Workspace Workspace?
|
Workspace Workspace?
|
||||||
IntegrationAccount IntegrationAccount[]
|
IntegrationAccount IntegrationAccount[]
|
||||||
@ -606,10 +606,10 @@ model WebhookConfiguration {
|
|||||||
|
|
||||||
model WebhookDeliveryLog {
|
model WebhookDeliveryLog {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
webhookConfiguration WebhookConfiguration @relation(fields: [webhookConfigurationId], references: [id])
|
webhookConfiguration WebhookConfiguration @relation(fields: [webhookConfigurationId], references: [id], onDelete: Cascade)
|
||||||
webhookConfigurationId String
|
webhookConfigurationId String
|
||||||
|
|
||||||
activity Activity? @relation(fields: [activityId], references: [id])
|
activity Activity? @relation(fields: [activityId], references: [id], onDelete: Cascade)
|
||||||
activityId String?
|
activityId String?
|
||||||
|
|
||||||
status WebhookDeliveryStatus
|
status WebhookDeliveryStatus
|
||||||
@ -680,7 +680,7 @@ model BillingHistory {
|
|||||||
stripePaymentStatus String?
|
stripePaymentStatus String?
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
subscription Subscription @relation(fields: [subscriptionId], references: [id])
|
subscription Subscription @relation(fields: [subscriptionId], references: [id], onDelete: Cascade)
|
||||||
subscriptionId String
|
subscriptionId String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user