-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
122 lines (101 loc) · 3.34 KB
/
schema.prisma
File metadata and controls
122 lines (101 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// 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 = "sqlite"
url = "file:./hyperpost.db"
}
model Post {
id String @id @default(cuid())
contentHash String @unique
title String?
content String
url String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Relations
postPlatforms PostPlatform[]
@@map("posts")
}
model Platform {
id String @id @default(cuid())
name String @unique // mastodon, bluesky, reddit, discord
displayName String
createdAt DateTime @default(now())
// Relations
postPlatforms PostPlatform[]
@@map("platforms")
}
model PostPlatform {
id String @id @default(cuid())
postId String
platformId String
postUrl String? // URL of the post on the platform
postedAt DateTime @default(now())
// Relations
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
platform Platform @relation(fields: [platformId], references: [id], onDelete: Cascade)
analytics PostAnalytics[] // Relation to analytics
@@unique([postId, platformId])
@@map("post_platforms")
}
model PostAnalytics {
id String @id @default(cuid())
postPlatformId String
metric String // likes, reposts, replies, views, etc.
value Int @default(0)
recordedAt DateTime @default(now())
// Relations
postPlatform PostPlatform @relation(fields: [postPlatformId], references: [id], onDelete: Cascade)
@@unique([postPlatformId, metric])
@@map("post_analytics")
}
model ScheduledPost {
id String @id @default(cuid())
contentHash String
title String?
content String
url String?
tags String? // JSON array of tags
platforms String // JSON array of platform names
scheduledAt DateTime
status String @default("pending") // pending, posted, failed, cancelled
createdAt DateTime @default(now())
postedAt DateTime?
error String?
@@index([status, scheduledAt])
@@map("scheduled_posts")
}
model IntentSignal {
id String @id @default(cuid())
appName String
platform String // 'reddit' | 'x' | 'linkedin' | 'quora'
url String @unique
title String
excerpt String
intentScore Int @default(0) // 0-100
status String @default("new") // 'new' | 'drafting' | 'replied' | 'ignored'
createdAt DateTime @default(now())
drafts Draft[]
@@index([appName, status])
@@index([intentScore])
@@map("intent_signals")
}
model Draft {
id String @id @default(cuid())
appName String
platform String // 'reddit' | 'hackernews' | 'bluesky' | 'mastodon' | 'telegram' | 'devto'
content String
metadata String @default("{}") // JSON: subreddit, title, tags, threadUrl, etc.
status String @default("draft") // 'draft' | 'approved' | 'posted'
signalId String?
signal IntentSignal? @relation(fields: [signalId], references: [id], onDelete: SetNull)
createdAt DateTime @default(now())
postedAt DateTime?
@@index([appName, status])
@@map("drafts")
}
// Indexes for performance
// Note: Indexes are automatically created for @unique and foreign key fields