// 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 { provider = "postgresql" url = env("DATABASE_URL") } model Organization { id String @id @default(dbgenerated("gen_random_uuid()")) name String projects Project[] users User[] createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt clients Client[] Invite Invite[] @@map("organizations") } model Project { id String @id @default(dbgenerated("gen_random_uuid()")) name String organization_id String organization Organization @relation(fields: [organization_id], references: [id]) events Event[] profiles Profile[] clients Client[] createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt reports Report[] dashboards Dashboard[] RecentDashboards RecentDashboards[] @@map("projects") } model User { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid name String email String password String organization_id String organization Organization @relation(fields: [organization_id], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt RecentDashboards RecentDashboards[] @@map("users") } model Event { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid name String properties Json project_id String project Project @relation(fields: [project_id], references: [id]) profile_id String? @db.Uuid profile Profile? @relation(fields: [profile_id], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@map("events") } model Profile { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid external_id String? first_name String? last_name String? email String? avatar String? properties Json project_id String project Project @relation(fields: [project_id], references: [id]) events Event[] createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@map("profiles") } model EventFailed { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid data Json createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@map("event_failed") } model Client { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid name String secret String? project_id String project Project @relation(fields: [project_id], references: [id]) organization_id String organization Organization @relation(fields: [organization_id], references: [id]) cors String @default("*") createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@map("clients") } model RecentDashboards { id String @id @default(dbgenerated("gen_random_uuid()")) project_id String project Project @relation(fields: [project_id], references: [id]) organization_id String dashboard_id String dashboard Dashboard @relation(fields: [dashboard_id], references: [id]) user_id String @db.Uuid user User @relation(fields: [user_id], references: [id]) createdAt DateTime @default(now()) @@map("recent_dashboards") } enum Interval { hour day month minute } enum ChartType { linear bar histogram pie metric area } model Dashboard { id String @id @default(dbgenerated("gen_random_uuid()")) name String project_id String project Project @relation(fields: [project_id], references: [id]) reports Report[] createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt RecentDashboards RecentDashboards[] @@map("dashboards") } model Report { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid name String interval Interval range String @default("1m") chart_type ChartType line_type String @default("monotone") breakdowns Json events Json project_id String project Project @relation(fields: [project_id], references: [id]) previous Boolean @default(false) dashboard_id String dashboard Dashboard @relation(fields: [dashboard_id], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@map("reports") } model Invite { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid email String organization_id String organization Organization @relation(fields: [organization_id], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt accepted Boolean @default(false) @@map("invites") }