🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: drop redundant indexes on postgres (#3377)
Steffen Schmitz66e15bcf0dce
diff --git a/packages/shared/prisma/migrations/20240917183001_remove_covered_indexes_01/migration.sql b/packages/shared/prisma/migrations/20240917183001_remove_covered_indexes_01/migration.sqlnew file mode 100644index 0000000000..3775981534--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183001_remove_covered_indexes_01/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "traces_project_id_idx"; -- covered by traces_project_id_timestamp_idxdiff --git a/packages/shared/prisma/migrations/20240917183002_remove_covered_indexes_02/migration.sql b/packages/shared/prisma/migrations/20240917183002_remove_covered_indexes_02/migration.sqlnew file mode 100644index 0000000000..4921d9a985--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183002_remove_covered_indexes_02/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "datasets_project_id_idx"; -- covered by datasets_project_id_name_key (unique)diff --git a/packages/shared/prisma/migrations/20240917183003_remove_covered_indexes_03/migration.sql b/packages/shared/prisma/migrations/20240917183003_remove_covered_indexes_03/migration.sqlnew file mode 100644index 0000000000..7df2c300db--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183003_remove_covered_indexes_03/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "eval_templates_project_id_idx"; -- covered by eval_templates_project_id_id_idxdiff --git a/packages/shared/prisma/migrations/20240917183004_remove_covered_indexes_04/migration.sql b/packages/shared/prisma/migrations/20240917183004_remove_covered_indexes_04/migration.sqlnew file mode 100644index 0000000000..dca1bc215e--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183004_remove_covered_indexes_04/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "job_configurations_project_id_idx"; -- covered by job_configurations_project_id_id_idxdiff --git a/packages/shared/prisma/migrations/20240917183005_remove_covered_indexes_05/migration.sql b/packages/shared/prisma/migrations/20240917183005_remove_covered_indexes_05/migration.sqlnew file mode 100644index 0000000000..e4a560f88f--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183005_remove_covered_indexes_05/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "job_executions_project_id_idx"; -- covered by job_executions_project_id_id_idxdiff --git a/packages/shared/prisma/migrations/20240917183006_remove_covered_indexes_06/migration.sql b/packages/shared/prisma/migrations/20240917183006_remove_covered_indexes_06/migration.sqlnew file mode 100644index 0000000000..de56401569--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183006_remove_covered_indexes_06/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "llm_api_keys_project_id_provider_idx"; -- covered by llm_api_keys_project_id_provider_key (unique)diff --git a/packages/shared/prisma/migrations/20240917183007_remove_covered_indexes_07/migration.sql b/packages/shared/prisma/migrations/20240917183007_remove_covered_indexes_07/migration.sqlnew file mode 100644index 0000000000..bdd97a461f--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183007_remove_covered_indexes_07/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "models_project_id_model_name_idx"; -- covered by models_project_id_model_name_start_date_unit_key (unique)diff --git a/packages/shared/prisma/migrations/20240917183008_remove_covered_indexes_08/migration.sql b/packages/shared/prisma/migrations/20240917183008_remove_covered_indexes_08/migration.sqlnew file mode 100644index 0000000000..8e0481523b--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183008_remove_covered_indexes_08/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "models_project_id_model_name_start_date_unit_idx"; -- covered by models_project_id_model_name_start_date_unit_key (unique)diff --git a/packages/shared/prisma/migrations/20240917183009_remove_covered_indexes_09/migration.sql b/packages/shared/prisma/migrations/20240917183009_remove_covered_indexes_09/migration.sqlnew file mode 100644index 0000000000..599fb0da9e--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183009_remove_covered_indexes_09/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "observations_project_id_idx"; -- covered by observations_project_id_start_time_type_idxdiff --git a/packages/shared/prisma/migrations/20240917183010_remove_covered_indexes_10/migration.sql b/packages/shared/prisma/migrations/20240917183010_remove_covered_indexes_10/migration.sqlnew file mode 100644index 0000000000..8a2e52d0fc--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183010_remove_covered_indexes_10/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "observations_trace_id_idx"; -- covered by observations_trace_id_project_id_start_time_idxdiff --git a/packages/shared/prisma/migrations/20240917183011_remove_covered_indexes_11/migration.sql b/packages/shared/prisma/migrations/20240917183011_remove_covered_indexes_11/migration.sqlnew file mode 100644index 0000000000..500a27ca7d--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183011_remove_covered_indexes_11/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "observations_trace_id_project_id_idx"; -- covered by observations_trace_id_project_id_start_time_idxdiff --git a/packages/shared/prisma/migrations/20240917183012_remove_covered_indexes_12/migration.sql b/packages/shared/prisma/migrations/20240917183012_remove_covered_indexes_12/migration.sqlnew file mode 100644index 0000000000..df196503bf--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183012_remove_covered_indexes_12/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "organization_memberships_org_id_idx"; -- covered by organization_memberships_org_id_user_id_key (unique)diff --git a/packages/shared/prisma/migrations/20240917183013_remove_covered_indexes_13/migration.sql b/packages/shared/prisma/migrations/20240917183013_remove_covered_indexes_13/migration.sqlnew file mode 100644index 0000000000..bd55006591--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183013_remove_covered_indexes_13/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "posthog_integrations_project_id_idx"; -- covered by posthog_integrations_pkey (unique)diff --git a/packages/shared/prisma/migrations/20240917183014_remove_covered_indexes_14/migration.sql b/packages/shared/prisma/migrations/20240917183014_remove_covered_indexes_14/migration.sqlnew file mode 100644index 0000000000..b931ea211c--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183014_remove_covered_indexes_14/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "prompts_project_id_idx"; -- covered by prompts_project_id_name_version_key (unique)diff --git a/packages/shared/prisma/migrations/20240917183015_remove_covered_indexes_15/migration.sql b/packages/shared/prisma/migrations/20240917183015_remove_covered_indexes_15/migration.sqlnew file mode 100644index 0000000000..7c9aac6d9b--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183015_remove_covered_indexes_15/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "prompts_project_id_name_version_idx"; -- covered by prompts_project_id_name_version_key (unique)diff --git a/packages/shared/prisma/migrations/20240917183016_remove_covered_indexes_16/migration.sql b/packages/shared/prisma/migrations/20240917183016_remove_covered_indexes_16/migration.sqlnew file mode 100644index 0000000000..a8f9ca0a74--- /dev/null+++ b/packages/shared/prisma/migrations/20240917183016_remove_covered_indexes_16/migration.sql@@ -0,0 +1,3 @@+-- DropIndex+-- Removes indexes that are covered by other indexes on the same table, e.g. (project_id) if (project_id, timestamp) exists.+DROP INDEX CONCURRENTLY IF EXISTS "scores_project_id_idx"; -- covered by scores_project_id_name_idxdiff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 0471ebf32b..4f50052000 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -2,889 +2,873 @@// learn more about it in the docs: https://pris.ly/d/prisma-schemagenerator client {- provider = "prisma-client-js"- previewFeatures = ["tracing", "views", "relationJoins", "metrics"]+ provider = "prisma-client-js"+ previewFeatures = ["tracing", "views", "relationJoins", "metrics"]}datasource db {- provider = "postgresql"- url = env("DATABASE_URL")- directUrl = env("DIRECT_URL")- shadowDatabaseUrl = env("SHADOW_DATABASE_URL")+ provider = "postgresql"+ url = env("DATABASE_URL")+ directUrl = env("DIRECT_URL")+ shadowDatabaseUrl = env("SHADOW_DATABASE_URL")}generator erd {- provider = "prisma-erd-generator"- ignoreTables = ["_prisma_migrations", "Session", "Account", "Example"]- disabled = true- ignoreEnums = true- output = "database.svg"+ provider = "prisma-erd-generator"+ ignoreTables = ["_prisma_migrations", "Session", "Account", "Example"]+ disabled = true+ ignoreEnums = true+ output = "database.svg"}generator kysely {- provider = "prisma-kysely"+ provider = "prisma-kysely"- // Optionally provide a destination directory for the generated file- // and a filename of your choice- // output = "../src/db"- // fileName = "types.ts"- // Optionally generate runtime enums to a separate file- // enumFileName = "enums.ts"+ // Optionally provide a destination directory for the generated file+ // and a filename of your choice+ // output = "../src/db"+ // fileName = "types.ts"+ // Optionally generate runtime enums to a separate file+ // enumFileName = "enums.ts"}// Necessary for Next authmodel Account {- id String @id @default(cuid())- userId String @map("user_id")- type String- provider String- providerAccountId String- refresh_token String? // @db.Text- access_token String? // @db.Text- expires_at Int?- expires_in Int?- ext_expires_in Int?- token_type String?- scope String?- id_token String? // @db.Text- session_state String?- refresh_token_expires_in Int?- user User @relation(fields: [userId], references: [id], onDelete: Cascade)-- @@unique([provider, providerAccountId])- @@index([userId])+ id String @id @default(cuid())+ userId String @map("user_id")+ type String+ provider String+ providerAccountId String+ refresh_token String? // @db.Text+ access_token String? // @db.Text+ expires_at Int?+ expires_in Int?+ ext_expires_in Int?+ token_type String?+ scope String?+ id_token String? // @db.Text+ session_state String?+ refresh_token_expires_in Int?+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)++ @@unique([provider, providerAccountId])+ @@index([userId])}model Session {- id String @id @default(cuid())- sessionToken String @unique @map("session_token")- userId String @map("user_id")- expires DateTime- user User @relation(fields: [userId], references: [id], onDelete: Cascade)+ id String @id @default(cuid())+ sessionToken String @unique @map("session_token")+ userId String @map("user_id")+ expires DateTime+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)}model User {- id String @id @default(cuid())- name String?- email String? @unique- emailVerified DateTime? @map("email_verified")- password String?- image String?- admin Boolean @default(false)- accounts Account[]- sessions Session[]- organizationMemberships OrganizationMembership[]- projectMemberships ProjectMembership[]- invitations MembershipInvitation[]- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- featureFlags String[] @default([]) @map("feature_flags")-- @@map("users")+ id String @id @default(cuid())+ name String?+ email String? @unique+ emailVerified DateTime? @map("email_verified")+ password String?+ image String?+ admin Boolean @default(false)+ accounts Account[]+ sessions Session[]+ organizationMemberships OrganizationMembership[]+ projectMemberships ProjectMembership[]+ invitations MembershipInvitation[]+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ featureFlags String[] @default([]) @map("feature_flags")++ @@map("users")}model VerificationToken {- identifier String- token String @unique- expires DateTime+ identifier String+ token String @unique+ expires DateTime- @@unique([identifier, token])- @@map("verification_tokens")+ @@unique([identifier, token])+ @@map("verification_tokens")}model Organization {- id String @id @default(cuid())- name String- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- cloudConfig Json? @map("cloud_config") // Langfuse Cloud, for zod schema see @/src/features/organizations/utils/cloudConfigSchema- organizationMemberships OrganizationMembership[]- projects Project[]- MembershipInvitation MembershipInvitation[]+ id String @id @default(cuid())+ name String+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ cloudConfig Json? @map("cloud_config") // Langfuse Cloud, for zod schema see @/src/features/organizations/utils/cloudConfigSchema+ organizationMemberships OrganizationMembership[]+ projects Project[]+ MembershipInvitation MembershipInvitation[]- @@map("organizations")+ @@map("organizations")}model Project {- id String @id @default(cuid())- orgId String @map("org_id")- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- name String- projectMembers ProjectMembership[]- organization Organization @relation(fields: [orgId], references: [id], onUpdate: Cascade, onDelete: Cascade)- traces Trace[]- observations Observation[]- apiKeys ApiKey[]- dataset Dataset[]- RawEvents Events[]- invitations MembershipInvitation[]- sessions TraceSession[]- Prompt Prompt[]- Model Model[]- EvalTemplate EvalTemplate[]- JobConfiguration JobConfiguration[]- JobExecution JobExecution[]- LlmApiKeys LlmApiKeys[]- PosthogIntegration PosthogIntegration[]- Score Score[]- scoreConfig ScoreConfig[]- BatchExport BatchExport[]- comment Comment[]-- @@index([orgId])- @@map("projects")+ id String @id @default(cuid())+ orgId String @map("org_id")+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ name String+ projectMembers ProjectMembership[]+ organization Organization @relation(fields: [orgId], references: [id], onUpdate: Cascade, onDelete: Cascade)+ traces Trace[]+ observations Observation[]+ apiKeys ApiKey[]+ dataset Dataset[]+ RawEvents Events[]+ invitations MembershipInvitation[]+ sessions TraceSession[]+ Prompt Prompt[]+ Model Model[]+ EvalTemplate EvalTemplate[]+ JobConfiguration JobConfiguration[]+ JobExecution JobExecution[]+ LlmApiKeys LlmApiKeys[]+ PosthogIntegration PosthogIntegration[]+ Score Score[]+ scoreConfig ScoreConfig[]+ BatchExport BatchExport[]+ comment Comment[]++ @@index([orgId])+ @@map("projects")}model ApiKey {- id String @id @unique @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- note String?- publicKey String @unique @map("public_key")- hashedSecretKey String @unique @map("hashed_secret_key")- fastHashedSecretKey String? @unique @map("fast_hashed_secret_key")- displaySecretKey String @map("display_secret_key")- lastUsedAt DateTime? @map("last_used_at")- expiresAt DateTime? @map("expires_at")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)-- @@index(projectId)- @@index(publicKey)- @@index(hashedSecretKey)- @@index(fastHashedSecretKey)- @@map("api_keys")+ id String @id @unique @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ note String?+ publicKey String @unique @map("public_key")+ hashedSecretKey String @unique @map("hashed_secret_key")+ fastHashedSecretKey String? @unique @map("fast_hashed_secret_key")+ displaySecretKey String @map("display_secret_key")+ lastUsedAt DateTime? @map("last_used_at")+ expiresAt DateTime? @map("expires_at")+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)++ @@index(projectId)+ @@index(publicKey)+ @@index(hashedSecretKey)+ @@index(fastHashedSecretKey)+ @@map("api_keys")}model LlmApiKeys {- id String @id @unique @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ id String @id @unique @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- provider String- adapter String // This controls the interface that is used to connect with the LLM, e.g. 'openai' or 'anthropic'- displaySecretKey String @map("display_secret_key")- secretKey String @map("secret_key")- baseURL String? @map("base_url")- customModels String[] @default([]) @map("custom_models")- withDefaultModels Boolean @default(true) @map("with_default_models")+ provider String+ adapter String // This controls the interface that is used to connect with the LLM, e.g. 'openai' or 'anthropic'+ displaySecretKey String @map("display_secret_key")+ secretKey String @map("secret_key")+ baseURL String? @map("base_url")+ customModels String[] @default([]) @map("custom_models")+ withDefaultModels Boolean @default(true) @map("with_default_models")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- @@unique([projectId, provider])- @@index([projectId, provider])- @@map("llm_api_keys")+ @@unique([projectId, provider])+ @@map("llm_api_keys")}model OrganizationMembership {- id String @id @default(cuid())- orgId String @map("org_id")- organization Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)- userId String @map("user_id")- user User @relation(fields: [userId], references: [id], onDelete: Cascade)- role Role @map("role")- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- ProjectMemberships ProjectMembership[]-- @@unique([orgId, userId])- @@index([userId])- @@index([orgId])- @@map("organization_memberships")+ id String @id @default(cuid())+ orgId String @map("org_id")+ organization Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)+ userId String @map("user_id")+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)+ role Role @map("role")+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ ProjectMemberships ProjectMembership[]++ @@unique([orgId, userId])+ @@index([userId])+ @@map("organization_memberships")}// Set a project-specific role for a user in an organizationmodel ProjectMembership {- orgMembershipId String @map("org_membership_id")- organizationMembership OrganizationMembership @relation(fields: [orgMembershipId], references: [id], onDelete: Cascade)- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- userId String @map("user_id")- user User @relation(fields: [userId], references: [id], onDelete: Cascade)- role Role- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- @@id([projectId, userId])- @@index([userId])- @@index([projectId])- @@index([orgMembershipId])- @@map("project_memberships")+ orgMembershipId String @map("org_membership_id")+ organizationMembership OrganizationMembership @relation(fields: [orgMembershipId], references: [id], onDelete: Cascade)+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ userId String @map("user_id")+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)+ role Role+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ @@id([projectId, userId])+ @@index([userId])+ @@index([projectId])+ @@index([orgMembershipId])+ @@map("project_memberships")}model MembershipInvitation {- id String @id @unique @default(cuid())- email String- orgId String @map("org_id")- organization Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)- orgRole Role @map("org_role")- projectId String? @map("project_id")- project Project? @relation(fields: [projectId], references: [id], onDelete: SetNull)- projectRole Role? @map("project_role")- invitedByUserId String? @map("invited_by_user_id")- invitedByUser User? @relation(fields: [invitedByUserId], references: [id], onDelete: SetNull)- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- @@index([projectId])- @@index([orgId])- @@index([email])- @@map("membership_invitations")+ id String @id @unique @default(cuid())+ email String+ orgId String @map("org_id")+ organization Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)+ orgRole Role @map("org_role")+ projectId String? @map("project_id")+ project Project? @relation(fields: [projectId], references: [id], onDelete: SetNull)+ projectRole Role? @map("project_role")+ invitedByUserId String? @map("invited_by_user_id")+ invitedByUser User? @relation(fields: [invitedByUserId], references: [id], onDelete: SetNull)+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ @@index([projectId])+ @@index([orgId])+ @@index([email])+ @@map("membership_invitations")}enum Role {- OWNER- ADMIN- MEMBER- VIEWER- NONE+ OWNER+ ADMIN+ MEMBER+ VIEWER+ NONE}model TraceSession {- id String @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- bookmarked Boolean @default(false)- public Boolean @default(false)- traces Trace[]-- @@id([id, projectId])- @@index([projectId])- @@index([createdAt])- @@index([updatedAt])- @@map("trace_sessions")+ id String @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ bookmarked Boolean @default(false)+ public Boolean @default(false)+ traces Trace[]++ @@id([id, projectId])+ @@index([projectId])+ @@index([createdAt])+ @@index([updatedAt])+ @@map("trace_sessions")}// Update TraceView below when making changes to this model!model Trace {- id String @id @default(cuid())- externalId String? @map("external_id")- timestamp DateTime @default(now())- name String?- userId String? @map("user_id")- metadata Json?- release String?- version String?- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- public Boolean @default(false)- bookmarked Boolean @default(false)- tags String[] @default([])- input Json?- output Json?- sessionId String? @map("session_id")- session TraceSession? @relation(fields: [sessionId, projectId], references: [id, projectId])- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- JobExecution JobExecution[]-- @@index([projectId])- @@index([projectId, timestamp])- @@index([sessionId])- @@index([name])- @@index([userId])- @@index([id, userId])- @@index(timestamp)- @@index(createdAt)- @@index([tags(ops: ArrayOps)], type: Gin)- @@map("traces")+ id String @id @default(cuid())+ externalId String? @map("external_id")+ timestamp DateTime @default(now())+ name String?+ userId String? @map("user_id")+ metadata Json?+ release String?+ version String?+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ public Boolean @default(false)+ bookmarked Boolean @default(false)+ tags String[] @default([])+ input Json?+ output Json?+ sessionId String? @map("session_id")+ session TraceSession? @relation(fields: [sessionId, projectId], references: [id, projectId])+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ JobExecution JobExecution[]++ @@index([projectId, timestamp])+ @@index([sessionId])+ @@index([name])+ @@index([userId])+ @@index([id, userId])+ @@index(timestamp)+ @@index(createdAt)+ @@index([tags(ops: ArrayOps)], type: Gin)+ @@map("traces")}// This view is based on the trace table. Once prisma supports// inheritance, we should remove code duplication here.view TraceView {- // trace fields- id String @id @default(cuid())- externalId String? @map("external_id")- timestamp DateTime @default(now())- name String?- userId String? @map("user_id")- metadata Json?- release String?- version String?- projectId String @map("project_id")- public Boolean @default(false)- bookmarked Boolean @default(false)- tags String[] @default([])- input Json?- output Json?- sessionId String? @map("session_id")- createdAt DateTime @map("created_at")- updatedAt DateTime @map("updated_at")-- // calculated fields- duration Float? @map("duration") // can be null if no observations in trace-- @@map("traces_view")+ // trace fields+ id String @id @default(cuid())+ externalId String? @map("external_id")+ timestamp DateTime @default(now())+ name String?+ userId String? @map("user_id")+ metadata Json?+ release String?+ version String?+ projectId String @map("project_id")+ public Boolean @default(false)+ bookmarked Boolean @default(false)+ tags String[] @default([])+ input Json?+ output Json?+ sessionId String? @map("session_id")+ createdAt DateTime @map("created_at")+ updatedAt DateTime @map("updated_at")++ // calculated fields+ duration Float? @map("duration") // can be null if no observations in trace++ @@map("traces_view")}// Update ObservationView below when making changes to this model!// traceId is optional only due to timing during data injestion// (traceId is not necessarily known at the time of observation creation)model Observation {- id String @id @default(cuid())- traceId String? @map("trace_id")- projectId String @map("project_id")- type ObservationType- startTime DateTime @default(now()) @map("start_time")- endTime DateTime? @map("end_time")- name String?- metadata Json?- parentObservationId String? @map("parent_observation_id")- level ObservationLevel @default(DEFAULT)- statusMessage String? @map("status_message")- version String?- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- // GENERATION ONLY- model String? // user-provided model attribute- internalModel String? @map("internal_model") // matched model.name that is matched at ingestion time, to be deprecated- internalModelId String? @map("internal_model_id") // matched model.id that is matched at ingestion time-- modelParameters Json?- input Json?- output Json?- promptTokens Int @default(0) @map("prompt_tokens")- completionTokens Int @default(0) @map("completion_tokens")- totalTokens Int @default(0) @map("total_tokens")- unit String?-- // User provided cost at ingestion- inputCost Decimal? @map("input_cost")- outputCost Decimal? @map("output_cost")- totalCost Decimal? @map("total_cost")-- // Calculated cost- calculatedInputCost Decimal? @map("calculated_input_cost")- calculatedOutputCost Decimal? @map("calculated_output_cost")- calculatedTotalCost Decimal? @map("calculated_total_cost")-- completionStartTime DateTime? @map("completion_start_time")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)-- promptId String? @map("prompt_id") // no fk constraint, prompt can be deleted-- @@unique([id, projectId])- @@index([projectId, internalModel, startTime, unit])- @@index([traceId, projectId, type, startTime])- @@index([traceId, projectId, startTime])- @@index([traceId, projectId])- @@index([traceId])- @@index([type])- @@index(startTime)- @@index(createdAt)- @@index(projectId)- @@index(model)- @@index(internalModel)- @@index([projectId, promptId])- @@index(promptId)- @@index([projectId, startTime, type])- @@map("observations")+ id String @id @default(cuid())+ traceId String? @map("trace_id")+ projectId String @map("project_id")+ type ObservationType+ startTime DateTime @default(now()) @map("start_time")+ endTime DateTime? @map("end_time")+ name String?+ metadata Json?+ parentObservationId String? @map("parent_observation_id")+ level ObservationLevel @default(DEFAULT)+ statusMessage String? @map("status_message")+ version String?+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ // GENERATION ONLY+ model String? // user-provided model attribute+ internalModel String? @map("internal_model") // matched model.name that is matched at ingestion time, to be deprecated+ internalModelId String? @map("internal_model_id") // matched model.id that is matched at ingestion time++ modelParameters Json?+ input Json?+ output Json?+ promptTokens Int @default(0) @map("prompt_tokens")+ completionTokens Int @default(0) @map("completion_tokens")+ totalTokens Int @default(0) @map("total_tokens")+ unit String?++ // User provided cost at ingestion+ inputCost Decimal? @map("input_cost")+ outputCost Decimal? @map("output_cost")+ totalCost Decimal? @map("total_cost")++ // Calculated cost+ calculatedInputCost Decimal? @map("calculated_input_cost")+ calculatedOutputCost Decimal? @map("calculated_output_cost")+ calculatedTotalCost Decimal? @map("calculated_total_cost")++ completionStartTime DateTime? @map("completion_start_time")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)++ promptId String? @map("prompt_id") // no fk constraint, prompt can be deleted++ @@unique([id, projectId])+ @@index([projectId, internalModel, startTime, unit])+ @@index([traceId, projectId, type, startTime])+ @@index([traceId, projectId, startTime])+ @@index([type])+ @@index(startTime)+ @@index(createdAt)+ @@index(model)+ @@index(internalModel)+ @@index([projectId, promptId])+ @@index(promptId)+ @@index([projectId, startTime, type])+ @@map("observations")}// This view is a mix of the observation and model. Once prisma supports// inheritance, we should remove code duplication here.view ObservationView {- id String @id @default(cuid())- traceId String? @map("trace_id")- projectId String @map("project_id")- type ObservationType- startTime DateTime @map("start_time")- endTime DateTime? @map("end_time")- name String?- metadata Json?- parentObservationId String? @map("parent_observation_id")- level ObservationLevel @default(DEFAULT)- statusMessage String? @map("status_message")- version String?- createdAt DateTime @map("created_at")- updatedAt DateTime @map("updated_at")-- // GENERATION ONLY- model String?- modelParameters Json?- input Json?- output Json?- promptTokens Int @default(0) @map("prompt_tokens")- completionTokens Int @default(0) @map("completion_tokens")- totalTokens Int @default(0) @map("total_tokens")- unit String?- completionStartTime DateTime? @map("completion_start_time")-- // prompts- promptId String? @map("prompt_id")- promptName String? @map("prompt_name")- promptVersion Int? @map("prompt_version")-- // model fields- modelId String? @map("model_id")- inputPrice Decimal? @map("input_price")- outputPrice Decimal? @map("output_price")- totalPrice Decimal? @map("total_price")-- // calculated fields- calculatedInputCost Decimal? @map("calculated_input_cost")- calculatedOutputCost Decimal? @map("calculated_output_cost")- calculatedTotalCost Decimal? @map("calculated_total_cost")- latency Float? @map("latency")- timeToFirstToken Float? @map("time_to_first_token")-- @@map("observations_view")+ id String @id @default(cuid())+ traceId String? @map("trace_id")+ projectId String @map("project_id")+ type ObservationType+ startTime DateTime @map("start_time")+ endTime DateTime? @map("end_time")+ name String?+ metadata Json?+ parentObservationId String? @map("parent_observation_id")+ level ObservationLevel @default(DEFAULT)+ statusMessage String? @map("status_message")+ version String?+ createdAt DateTime @map("created_at")+ updatedAt DateTime @map("updated_at")++ // GENERATION ONLY+ model String?+ modelParameters Json?+ input Json?+ output Json?+ promptTokens Int @default(0) @map("prompt_tokens")+ completionTokens Int @default(0) @map("completion_tokens")+ totalTokens Int @default(0) @map("total_tokens")+ unit String?+ completionStartTime DateTime? @map("completion_start_time")++ // prompts+ promptId String? @map("prompt_id")+ promptName String? @map("prompt_name")+ promptVersion Int? @map("prompt_version")++ // model fields+ modelId String? @map("model_id")+ inputPrice Decimal? @map("input_price")+ outputPrice Decimal? @map("output_price")+ totalPrice Decimal? @map("total_price")++ // calculated fields+ calculatedInputCost Decimal? @map("calculated_input_cost")+ calculatedOutputCost Decimal? @map("calculated_output_cost")+ calculatedTotalCost Decimal? @map("calculated_total_cost")+ latency Float? @map("latency")+ timeToFirstToken Float? @map("time_to_first_token")++ @@map("observations_view")}enum ObservationType {- SPAN- EVENT- GENERATION+ SPAN+ EVENT+ GENERATION}enum ObservationLevel {- DEBUG- DEFAULT- WARNING- ERROR+ DEBUG+ DEFAULT+ WARNING+ ERROR}model Score {- id String @id @default(cuid())- timestamp DateTime @default(now())- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- name String- value Float? // always defined if data type is NUMERIC or BOOLEAN, optional for CATEGORICAL- source ScoreSource- authorUserId String? @map("author_user_id")- comment String?- traceId String @map("trace_id")- observationId String? @map("observation_id")- configId String? @map("config_id")- stringValue String? @map("string_value") // always defined if data type is CATEGORICAL or BOOLEAN, null for NUMERIC- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- dataType ScoreDataType @default(NUMERIC) @map("data_type")- JobExecution JobExecution[]- scoreConfig ScoreConfig? @relation(fields: [configId], references: [id], onDelete: SetNull)-- @@unique([id, projectId]) // used for upserts via prisma- @@index(timestamp)- @@index([value])- @@index([projectId])- @@index([projectId, name])- @@index([authorUserId])- @@index([configId])- @@index([traceId], type: Hash)- @@index([observationId], type: Hash)- @@index([source])- @@index([createdAt])- @@map("scores")+ id String @id @default(cuid())+ timestamp DateTime @default(now())+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ name String+ value Float? // always defined if data type is NUMERIC or BOOLEAN, optional for CATEGORICAL+ source ScoreSource+ authorUserId String? @map("author_user_id")+ comment String?+ traceId String @map("trace_id")+ observationId String? @map("observation_id")+ configId String? @map("config_id")+ stringValue String? @map("string_value") // always defined if data type is CATEGORICAL or BOOLEAN, null for NUMERIC+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ dataType ScoreDataType @default(NUMERIC) @map("data_type")+ JobExecution JobExecution[]+ scoreConfig ScoreConfig? @relation(fields: [configId], references: [id], onDelete: SetNull)++ @@unique([id, projectId]) // used for upserts via prisma+ @@index(timestamp)+ @@index([value])+ @@index([projectId, name])+ @@index([authorUserId])+ @@index([configId])+ @@index([traceId], type: Hash)+ @@index([observationId], type: Hash)+ @@index([source])+ @@index([createdAt])+ @@map("scores")}enum ScoreSource {- ANNOTATION- API- EVAL+ ANNOTATION+ API+ EVAL}model ScoreConfig {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- name String- dataType ScoreDataType @map("data_type")- isArchived Boolean @default(false) @map("is_archived")- minValue Float? @map("min_value")- maxValue Float? @map("max_value")- categories Json? @map("categories")- description String?- score Score[]-- @@unique([id, projectId]) // used for upserts via prisma- @@index([dataType])- @@index([isArchived])- @@index([projectId])- @@index([categories])- @@index([createdAt])- @@index([updatedAt])- @@map("score_configs")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ name String+ dataType ScoreDataType @map("data_type")+ isArchived Boolean @default(false) @map("is_archived")+ minValue Float? @map("min_value")+ maxValue Float? @map("max_value")+ categories Json? @map("categories")+ description String?+ score Score[]++ @@unique([id, projectId]) // used for upserts via prisma+ @@index([dataType])+ @@index([isArchived])+ @@index([projectId])+ @@index([categories])+ @@index([createdAt])+ @@index([updatedAt])+ @@map("score_configs")}enum ScoreDataType {- CATEGORICAL- NUMERIC- BOOLEAN+ CATEGORICAL+ NUMERIC+ BOOLEAN}model CronJobs {- name String @id- lastRun DateTime? @map("last_run")- jobStartedAt DateTime? @map("job_started_at")- state String?+ name String @id+ lastRun DateTime? @map("last_run")+ jobStartedAt DateTime? @map("job_started_at")+ state String?- @@map("cron_jobs")+ @@map("cron_jobs")}model Dataset {- id String @default(cuid())- projectId String @map("project_id")- name String- description String?- metadata Json?- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- datasetItems DatasetItem[]- datasetRuns DatasetRuns[]-- @@id([id, projectId])- @@unique([projectId, name])- @@index([projectId], type: Hash)- @@index([createdAt])- @@index([updatedAt])- @@map("datasets")+ id String @default(cuid())+ projectId String @map("project_id")+ name String+ description String?+ metadata Json?+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ datasetItems DatasetItem[]+ datasetRuns DatasetRuns[]++ @@id([id, projectId])+ @@unique([projectId, name])+ @@index([createdAt])+ @@index([updatedAt])+ @@map("datasets")}model DatasetItem {- id String @default(cuid())- projectId String @map("project_id")- status DatasetStatus @default(ACTIVE)- input Json?- expectedOutput Json? @map("expected_output")- metadata Json?- sourceTraceId String? @map("source_trace_id")- sourceObservationId String? @map("source_observation_id")- datasetId String @map("dataset_id")- dataset Dataset @relation(fields: [datasetId, projectId], references: [id, projectId], onDelete: Cascade)- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- datasetRunItems DatasetRunItems[]-- @@id([id, projectId])- @@index([sourceTraceId], type: Hash)- @@index([sourceObservationId], type: Hash)- @@index([datasetId], type: Hash)- @@index([createdAt])- @@index([updatedAt])- @@map("dataset_items")+ id String @default(cuid())+ projectId String @map("project_id")+ status DatasetStatus @default(ACTIVE)+ input Json?+ expectedOutput Json? @map("expected_output")+ metadata Json?+ sourceTraceId String? @map("source_trace_id")+ sourceObservationId String? @map("source_observation_id")+ datasetId String @map("dataset_id")+ dataset Dataset @relation(fields: [datasetId, projectId], references: [id, projectId], onDelete: Cascade)+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ datasetRunItems DatasetRunItems[]++ @@id([id, projectId])+ @@index([sourceTraceId], type: Hash)+ @@index([sourceObservationId], type: Hash)+ @@index([datasetId], type: Hash)+ @@index([createdAt])+ @@index([updatedAt])+ @@map("dataset_items")}enum DatasetStatus {- ACTIVE- ARCHIVED+ ACTIVE+ ARCHIVED}model DatasetRuns {- id String @default(cuid())- projectId String @map("project_id")- name String- description String?- metadata Json?- datasetId String @map("dataset_id")- dataset Dataset @relation(fields: [datasetId, projectId], references: [id, projectId], onDelete: Cascade)- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- datasetRunItems DatasetRunItems[]-- @@id([id, projectId])- @@unique([datasetId, projectId, name])- @@index([datasetId], type: Hash)- @@index([createdAt])- @@index([updatedAt])- @@map("dataset_runs")+ id String @default(cuid())+ projectId String @map("project_id")+ name String+ description String?+ metadata Json?+ datasetId String @map("dataset_id")+ dataset Dataset @relation(fields: [datasetId, projectId], references: [id, projectId], onDelete: Cascade)+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ datasetRunItems DatasetRunItems[]++ @@id([id, projectId])+ @@unique([datasetId, projectId, name])+ @@index([datasetId], type: Hash)+ @@index([createdAt])+ @@index([updatedAt])+ @@map("dataset_runs")}model DatasetRunItems {- id String @default(cuid())- projectId String @map("project_id")- datasetRunId String @map("dataset_run_id")- datasetRun DatasetRuns @relation(fields: [datasetRunId, projectId], references: [id, projectId], onDelete: Cascade)- datasetItemId String @map("dataset_item_id")- datasetItem DatasetItem @relation(fields: [datasetItemId, projectId], references: [id, projectId], onDelete: Cascade)- traceId String @map("trace_id")- observationId String? @map("observation_id")- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- @@id([id, projectId])- @@index([datasetRunId], type: Hash)- @@index([datasetItemId], type: Hash)- @@index([observationId], type: Hash)- @@index([traceId])- @@index([createdAt])- @@index([updatedAt])- @@map("dataset_run_items")+ id String @default(cuid())+ projectId String @map("project_id")+ datasetRunId String @map("dataset_run_id")+ datasetRun DatasetRuns @relation(fields: [datasetRunId, projectId], references: [id, projectId], onDelete: Cascade)+ datasetItemId String @map("dataset_item_id")+ datasetItem DatasetItem @relation(fields: [datasetItemId, projectId], references: [id, projectId], onDelete: Cascade)+ traceId String @map("trace_id")+ observationId String? @map("observation_id")+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ @@id([id, projectId])+ @@index([datasetRunId], type: Hash)+ @@index([datasetItemId], type: Hash)+ @@index([observationId], type: Hash)+ @@index([traceId])+ @@index([createdAt])+ @@index([updatedAt])+ @@map("dataset_run_items")}model Events {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- data Json- headers Json @default("{}")- url String?- method String?+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ data Json+ headers Json @default("{}")+ url String?+ method String?- @@index(projectId)- @@map("events")+ @@index(projectId)+ @@map("events")}model Comment {- id String @id @default(cuid())- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- objectType CommentObjectType @map("object_type")- objectId String @map("object_id")- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- content String- authorUserId String? @map("author_user_id") // no fk constraint, user can be deleted+ id String @id @default(cuid())+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ objectType CommentObjectType @map("object_type")+ objectId String @map("object_id")+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ content String+ authorUserId String? @map("author_user_id") // no fk constraint, user can be deleted- @@index([projectId, objectType, objectId])- @@map("comments")+ @@index([projectId, objectType, objectId])+ @@map("comments")}enum CommentObjectType {- TRACE- OBSERVATION- SESSION- PROMPT+ TRACE+ OBSERVATION+ SESSION+ PROMPT}model Prompt {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)-- createdBy String @map("created_by")-- prompt Json- name String- version Int- type String @default("text")- isActive Boolean? @map("is_active") // Deprecated. To be removed once 'production' labels work as expected.- config Json @default("{}")- tags String[] @default([])- labels String[] @default([])-- @@unique([projectId, name, version])- @@index([projectId, name, version])- @@index([projectId, id])- @@index([projectId])- @@index([createdAt])- @@index([updatedAt])- @@index([tags(ops: ArrayOps)], type: Gin)- @@map("prompts")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)++ createdBy String @map("created_by")++ prompt Json+ name String+ version Int+ type String @default("text")+ isActive Boolean? @map("is_active") // Deprecated. To be removed once 'production' labels work as expected.+ config Json @default("{}")+ tags String[] @default([])+ labels String[] @default([])++ @@unique([projectId, name, version])+ @@index([projectId, id])+ @@index([createdAt])+ @@index([updatedAt])+ @@index([tags(ops: ArrayOps)], type: Gin)+ @@map("prompts")}// Update ObservationView below when making changes to this model!model Model {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- projectId String? @map("project_id")- project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)-- modelName String @map("model_name")- matchPattern String @map("match_pattern")- startDate DateTime? @map("start_date")- inputPrice Decimal? @map("input_price")- outputPrice Decimal? @map("output_price")- totalPrice Decimal? @map("total_price")- unit String // TOKENS, CHARACTERS, MILLISECONDS, SECONDS, REQUESTS, or IMAGES- tokenizerId String? @map("tokenizer_id")- tokenizerConfig Json? @map("tokenizer_config")-- @@unique([projectId, modelName, startDate, unit])- @@index([projectId, modelName, startDate, unit])- @@index([projectId, modelName])- @@index(modelName)- @@map("models")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ projectId String? @map("project_id")+ project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)++ modelName String @map("model_name")+ matchPattern String @map("match_pattern")+ startDate DateTime? @map("start_date")+ inputPrice Decimal? @map("input_price")+ outputPrice Decimal? @map("output_price")+ totalPrice Decimal? @map("total_price")+ unit String // TOKENS, CHARACTERS, MILLISECONDS, SECONDS, REQUESTS, or IMAGES+ tokenizerId String? @map("tokenizer_id")+ tokenizerConfig Json? @map("tokenizer_config")++ @@unique([projectId, modelName, startDate, unit])+ @@index(modelName)+ @@map("models")}// No FK constraints to preserve audit logsmodel AuditLog {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- userId String @map("user_id")- orgId String @map("org_id")- userOrgRole String @map("user_org_role")- projectId String? @map("project_id")- userProjectRole String? @map("user_project_role")- resourceType String @map("resource_type")- resourceId String @map("resource_id")- action String- before String? //stringified JSON- after String? // stringified JSON-- @@index([projectId])- @@index([userId])- @@index([orgId])- @@index([createdAt])- @@index([updatedAt])- @@map("audit_logs")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ userId String @map("user_id")+ orgId String @map("org_id")+ userOrgRole String @map("user_org_role")+ projectId String? @map("project_id")+ userProjectRole String? @map("user_project_role")+ resourceType String @map("resource_type")+ resourceId String @map("resource_id")+ action String+ before String? //stringified JSON+ after String? // stringified JSON++ @@index([projectId])+ @@index([userId])+ @@index([orgId])+ @@index([createdAt])+ @@index([updatedAt])+ @@map("audit_logs")}model EvalTemplate {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- name String- version Int- prompt String- model String- provider String- modelParams Json @map("model_params")- vars String[] @default([])- outputSchema Json @map("output_schema")- JobConfiguration JobConfiguration[]+ name String+ version Int+ prompt String+ model String+ provider String+ modelParams Json @map("model_params")+ vars String[] @default([])+ outputSchema Json @map("output_schema")+ JobConfiguration JobConfiguration[]- @@unique([projectId, name, version])- @@index([projectId, id])- @@index([projectId])- @@map("eval_templates")+ @@unique([projectId, name, version])+ @@index([projectId, id])+ @@map("eval_templates")}enum JobType {- EVAL+ EVAL}enum JobConfigState {- ACTIVE- INACTIVE+ ACTIVE+ INACTIVE}model JobConfiguration {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- jobType JobType @map("job_type")- status JobConfigState @default(ACTIVE)- evalTemplateId String? @map("eval_template_id")- evalTemplate EvalTemplate? @relation(fields: [evalTemplateId], references: [id], onDelete: SetNull)+ jobType JobType @map("job_type")+ status JobConfigState @default(ACTIVE)+ evalTemplateId String? @map("eval_template_id")+ evalTemplate EvalTemplate? @relation(fields: [evalTemplateId], references: [id], onDelete: SetNull)- scoreName String @map("score_name")- filter Json- targetObject String @map("target_object")- variableMapping Json @map("variable_mapping")- sampling Decimal // ratio of jobs that are executed for sampling (0..1)- delay Int // delay in milliseconds- JobExecution JobExecution[]+ scoreName String @map("score_name")+ filter Json+ targetObject String @map("target_object")+ variableMapping Json @map("variable_mapping")+ sampling Decimal // ratio of jobs that are executed for sampling (0..1)+ delay Int // delay in milliseconds+ JobExecution JobExecution[]- @@index([projectId, id])- @@index([projectId])- @@map("job_configurations")+ @@index([projectId, id])+ @@map("job_configurations")}enum JobExecutionStatus {- COMPLETED- ERROR- PENDING- CANCELLED+ COMPLETED+ ERROR+ PENDING+ CANCELLED}model JobExecution {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- jobConfigurationId String @map("job_configuration_id")- jobConfiguration JobConfiguration @relation(fields: [jobConfigurationId], references: [id], onDelete: Cascade)+ jobConfigurationId String @map("job_configuration_id")+ jobConfiguration JobConfiguration @relation(fields: [jobConfigurationId], references: [id], onDelete: Cascade)- status JobExecutionStatus- startTime DateTime? @map("start_time")- endTime DateTime? @map("end_time")- error String?+ status JobExecutionStatus+ startTime DateTime? @map("start_time")+ endTime DateTime? @map("end_time")+ error String?- jobInputTraceId String? @map("job_input_trace_id")- trace Trace? @relation(fields: [jobInputTraceId], references: [id], onDelete: SetNull) // job remains when traces are deleted+ jobInputTraceId String? @map("job_input_trace_id")+ trace Trace? @relation(fields: [jobInputTraceId], references: [id], onDelete: SetNull) // job remains when traces are deleted- jobOutputScoreId String? @map("job_output_score_id")- score Score? @relation(fields: [jobOutputScoreId], references: [id], onDelete: SetNull) // job remains when scores are deleted+ jobOutputScoreId String? @map("job_output_score_id")+ score Score? @relation(fields: [jobOutputScoreId], references: [id], onDelete: SetNull) // job remains when scores are deleted- @@index([projectId, status])- @@index([projectId, id])- @@index([projectId])- @@index([jobConfigurationId])- @@index([jobOutputScoreId])- @@index([jobInputTraceId])- @@index([createdAt])- @@index([updatedAt])- @@map("job_executions")+ @@index([projectId, status])+ @@index([projectId, id])+ @@index([jobConfigurationId])+ @@index([jobOutputScoreId])+ @@index([jobInputTraceId])+ @@index([createdAt])+ @@index([updatedAt])+ @@map("job_executions")}// Single Sign-On configuration for a domain// This feature is part of the Enterprise Editionmodel SsoConfig {- domain String @id @default(cuid()) // e.g. "google.com"- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- authProvider String @map("auth_provider") // e.g. "okta", ee/sso/types.ts+ domain String @id @default(cuid()) // e.g. "google.com"+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")+ authProvider String @map("auth_provider") // e.g. "okta", ee/sso/types.ts- authConfig Json? @map("auth_config")- // e.g. { "clientId": "1234", "clientSecret": "5678" }, null if credentials from env should be used- // secrets like clientSecret are encrypted on the application level+ authConfig Json? @map("auth_config")+ // e.g. { "clientId": "1234", "clientSecret": "5678" }, null if credentials from env should be used+ // secrets like clientSecret are encrypted on the application level- @@map("sso_configs")+ @@map("sso_configs")}model PosthogIntegration {- projectId String @id @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- encryptedPosthogApiKey String @map("encrypted_posthog_api_key")- posthogHostName String @map("posthog_host_name")- lastSyncAt DateTime? @map("last_sync_at")- enabled Boolean- createdAt DateTime @default(now()) @map("created_at")+ projectId String @id @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ encryptedPosthogApiKey String @map("encrypted_posthog_api_key")+ posthogHostName String @map("posthog_host_name")+ lastSyncAt DateTime? @map("last_sync_at")+ enabled Boolean+ createdAt DateTime @default(now()) @map("created_at")- @@index([projectId])- @@map("posthog_integrations")+ @@map("posthog_integrations")}model BatchExport {- id String @id @default(cuid())- createdAt DateTime @default(now()) @map("created_at")- updatedAt DateTime @default(now()) @updatedAt @map("updated_at")-- projectId String @map("project_id")- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)- userId String @map("user_id")-- finishedAt DateTime? @map("finished_at")- expiresAt DateTime? @map("expires_at")-- name String- status String- query Json- format String- url String?- log String?-- @@index([projectId, userId])- @@index([status])- @@map("batch_exports")+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ userId String @map("user_id")++ finishedAt DateTime? @map("finished_at")+ expiresAt DateTime? @map("expires_at")++ name String+ status String+ query Json+ format String+ url String?+ log String?++ @@index([projectId, userId])+ @@index([status])+ @@map("batch_exports")}