@danielcok17/prisma-db 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +34 -19
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +5 -3
  5. package/dist/index.js.map +1 -1
  6. package/dist/utils.d.ts +4 -2
  7. package/dist/utils.d.ts.map +1 -1
  8. package/dist/utils.js +7 -4
  9. package/dist/utils.js.map +1 -1
  10. package/package.json +8 -7
  11. package/prisma/{schema.prisma → app.prisma} +3 -0
  12. package/prisma/generated/app/client.d.ts +1 -0
  13. package/prisma/generated/app/client.js +4 -0
  14. package/prisma/generated/app/default.d.ts +1 -0
  15. package/prisma/generated/app/default.js +4 -0
  16. package/prisma/generated/app/edge.d.ts +1 -0
  17. package/prisma/generated/app/edge.js +391 -0
  18. package/prisma/generated/app/index-browser.js +377 -0
  19. package/prisma/generated/app/index.d.ts +22435 -0
  20. package/prisma/generated/app/index.js +412 -0
  21. package/prisma/generated/app/libquery_engine-darwin-arm64.dylib.node +0 -0
  22. package/prisma/generated/app/package.json +150 -0
  23. package/prisma/generated/app/runtime/edge-esm.js +34 -0
  24. package/prisma/generated/app/runtime/edge.js +34 -0
  25. package/prisma/generated/app/runtime/index-browser.d.ts +370 -0
  26. package/prisma/generated/app/runtime/index-browser.js +16 -0
  27. package/prisma/generated/app/runtime/library.d.ts +4002 -0
  28. package/prisma/generated/app/runtime/library.js +146 -0
  29. package/prisma/generated/app/runtime/react-native.js +83 -0
  30. package/prisma/generated/app/runtime/wasm-compiler-edge.js +83 -0
  31. package/prisma/generated/app/runtime/wasm-engine-edge.js +35 -0
  32. package/prisma/generated/app/schema.prisma +284 -0
  33. package/prisma/generated/app/wasm.d.ts +1 -0
  34. package/prisma/generated/app/wasm.js +377 -0
  35. package/prisma/generated/law/client.d.ts +1 -0
  36. package/prisma/generated/law/client.js +4 -0
  37. package/prisma/generated/law/default.d.ts +1 -0
  38. package/prisma/generated/law/default.js +4 -0
  39. package/prisma/generated/law/edge.d.ts +1 -0
  40. package/prisma/generated/law/edge.js +251 -0
  41. package/prisma/generated/law/index-browser.js +237 -0
  42. package/prisma/generated/law/index.d.ts +6827 -0
  43. package/prisma/generated/law/index.js +272 -0
  44. package/prisma/generated/law/libquery_engine-darwin-arm64.dylib.node +0 -0
  45. package/prisma/generated/law/package.json +150 -0
  46. package/prisma/generated/law/runtime/edge-esm.js +34 -0
  47. package/prisma/generated/law/runtime/edge.js +34 -0
  48. package/prisma/generated/law/runtime/index-browser.d.ts +370 -0
  49. package/prisma/generated/law/runtime/index-browser.js +16 -0
  50. package/prisma/generated/law/runtime/library.d.ts +4002 -0
  51. package/prisma/generated/law/runtime/library.js +146 -0
  52. package/prisma/generated/law/runtime/react-native.js +83 -0
  53. package/prisma/generated/law/runtime/wasm-compiler-edge.js +83 -0
  54. package/prisma/generated/law/runtime/wasm-engine-edge.js +35 -0
  55. package/prisma/generated/law/schema.prisma +80 -0
  56. package/prisma/generated/law/wasm.d.ts +1 -0
  57. package/prisma/generated/law/wasm.js +237 -0
  58. package/prisma/law.prisma +82 -0
  59. package/prisma/migrations/20250817194531_/migration.sql +372 -0
  60. package/prisma/migrations/migration_lock.toml +3 -0
  61. package/prisma/seed.ts +0 -0
@@ -0,0 +1,237 @@
1
+
2
+ /* !!! This is code generated by Prisma. Do not edit directly. !!!
3
+ /* eslint-disable */
4
+
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+
7
+ const {
8
+ Decimal,
9
+ objectEnumValues,
10
+ makeStrictEnum,
11
+ Public,
12
+ getRuntime,
13
+ skip
14
+ } = require('./runtime/index-browser.js')
15
+
16
+
17
+ const Prisma = {}
18
+
19
+ exports.Prisma = Prisma
20
+ exports.$Enums = {}
21
+
22
+ /**
23
+ * Prisma Client JS version: 6.14.0
24
+ * Query Engine version: 717184b7b35ea05dfa71a3236b7af656013e1e49
25
+ */
26
+ Prisma.prismaVersion = {
27
+ client: "6.14.0",
28
+ engine: "717184b7b35ea05dfa71a3236b7af656013e1e49"
29
+ }
30
+
31
+ Prisma.PrismaClientKnownRequestError = () => {
32
+ const runtimeName = getRuntime().prettyName;
33
+ throw new Error(`PrismaClientKnownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
34
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
35
+ )};
36
+ Prisma.PrismaClientUnknownRequestError = () => {
37
+ const runtimeName = getRuntime().prettyName;
38
+ throw new Error(`PrismaClientUnknownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
39
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
40
+ )}
41
+ Prisma.PrismaClientRustPanicError = () => {
42
+ const runtimeName = getRuntime().prettyName;
43
+ throw new Error(`PrismaClientRustPanicError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
44
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
45
+ )}
46
+ Prisma.PrismaClientInitializationError = () => {
47
+ const runtimeName = getRuntime().prettyName;
48
+ throw new Error(`PrismaClientInitializationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
49
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
50
+ )}
51
+ Prisma.PrismaClientValidationError = () => {
52
+ const runtimeName = getRuntime().prettyName;
53
+ throw new Error(`PrismaClientValidationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
54
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
55
+ )}
56
+ Prisma.Decimal = Decimal
57
+
58
+ /**
59
+ * Re-export of sql-template-tag
60
+ */
61
+ Prisma.sql = () => {
62
+ const runtimeName = getRuntime().prettyName;
63
+ throw new Error(`sqltag is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
64
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
65
+ )}
66
+ Prisma.empty = () => {
67
+ const runtimeName = getRuntime().prettyName;
68
+ throw new Error(`empty is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
69
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
70
+ )}
71
+ Prisma.join = () => {
72
+ const runtimeName = getRuntime().prettyName;
73
+ throw new Error(`join is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
74
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
75
+ )}
76
+ Prisma.raw = () => {
77
+ const runtimeName = getRuntime().prettyName;
78
+ throw new Error(`raw is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
79
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
80
+ )}
81
+ Prisma.validator = Public.validator
82
+
83
+ /**
84
+ * Extensions
85
+ */
86
+ Prisma.getExtensionContext = () => {
87
+ const runtimeName = getRuntime().prettyName;
88
+ throw new Error(`Extensions.getExtensionContext is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
89
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
90
+ )}
91
+ Prisma.defineExtension = () => {
92
+ const runtimeName = getRuntime().prettyName;
93
+ throw new Error(`Extensions.defineExtension is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
94
+ In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
95
+ )}
96
+
97
+ /**
98
+ * Shorthand utilities for JSON filtering
99
+ */
100
+ Prisma.DbNull = objectEnumValues.instances.DbNull
101
+ Prisma.JsonNull = objectEnumValues.instances.JsonNull
102
+ Prisma.AnyNull = objectEnumValues.instances.AnyNull
103
+
104
+ Prisma.NullTypes = {
105
+ DbNull: objectEnumValues.classes.DbNull,
106
+ JsonNull: objectEnumValues.classes.JsonNull,
107
+ AnyNull: objectEnumValues.classes.AnyNull
108
+ }
109
+
110
+
111
+
112
+ /**
113
+ * Enums
114
+ */
115
+
116
+ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
117
+ ReadUncommitted: 'ReadUncommitted',
118
+ ReadCommitted: 'ReadCommitted',
119
+ RepeatableRead: 'RepeatableRead',
120
+ Serializable: 'Serializable'
121
+ });
122
+
123
+ exports.Prisma.LawVersionScalarFieldEnum = {
124
+ id: 'id',
125
+ lawId: 'lawId',
126
+ versionNumber: 'versionNumber',
127
+ lawUrl: 'lawUrl',
128
+ isLawVersionEffective: 'isLawVersionEffective',
129
+ isAmendment: 'isAmendment',
130
+ fullLawId: 'fullLawId',
131
+ approvalDate: 'approvalDate',
132
+ publicationDate: 'publicationDate',
133
+ effectiveFrom: 'effectiveFrom',
134
+ effectiveUntil: 'effectiveUntil',
135
+ author: 'author',
136
+ fullLawHtml: 'fullLawHtml',
137
+ fullLaw: 'fullLaw',
138
+ legalAreas: 'legalAreas',
139
+ publishedIn: 'publishedIn',
140
+ relationships: 'relationships'
141
+ };
142
+
143
+ exports.Prisma.LawAttachmentScalarFieldEnum = {
144
+ id: 'id',
145
+ name: 'name',
146
+ attachmentId: 'attachmentId',
147
+ content: 'content',
148
+ lawVersionId: 'lawVersionId'
149
+ };
150
+
151
+ exports.Prisma.VersionParagraphScalarFieldEnum = {
152
+ id: 'id',
153
+ paragraphId: 'paragraphId',
154
+ versionId: 'versionId',
155
+ sequenceNumber: 'sequenceNumber',
156
+ text: 'text',
157
+ fullText: 'fullText',
158
+ fullTextWithCitations: 'fullTextWithCitations',
159
+ embedding: 'embedding',
160
+ partId: 'partId',
161
+ partName: 'partName',
162
+ chapterId: 'chapterId',
163
+ chapterName: 'chapterName',
164
+ divisionId: 'divisionId',
165
+ divisionName: 'divisionName',
166
+ sectionId: 'sectionId',
167
+ sectionName: 'sectionName',
168
+ paragraphPath: 'paragraphPath',
169
+ paragraphGroupName: 'paragraphGroupName',
170
+ isAmendment: 'isAmendment',
171
+ validFrom: 'validFrom',
172
+ validTo: 'validTo'
173
+ };
174
+
175
+ exports.Prisma.SortOrder = {
176
+ asc: 'asc',
177
+ desc: 'desc'
178
+ };
179
+
180
+ exports.Prisma.NullableJsonNullValueInput = {
181
+ DbNull: Prisma.DbNull,
182
+ JsonNull: Prisma.JsonNull
183
+ };
184
+
185
+ exports.Prisma.QueryMode = {
186
+ default: 'default',
187
+ insensitive: 'insensitive'
188
+ };
189
+
190
+ exports.Prisma.JsonNullValueFilter = {
191
+ DbNull: Prisma.DbNull,
192
+ JsonNull: Prisma.JsonNull,
193
+ AnyNull: Prisma.AnyNull
194
+ };
195
+
196
+ exports.Prisma.NullsOrder = {
197
+ first: 'first',
198
+ last: 'last'
199
+ };
200
+
201
+
202
+ exports.Prisma.ModelName = {
203
+ LawVersion: 'LawVersion',
204
+ LawAttachment: 'LawAttachment',
205
+ VersionParagraph: 'VersionParagraph'
206
+ };
207
+
208
+ /**
209
+ * This is a stub Prisma Client that will error at runtime if called.
210
+ */
211
+ class PrismaClient {
212
+ constructor() {
213
+ return new Proxy(this, {
214
+ get(target, prop) {
215
+ let message
216
+ const runtime = getRuntime()
217
+ if (runtime.isEdge) {
218
+ message = `PrismaClient is not configured to run in ${runtime.prettyName}. In order to run Prisma Client on edge runtime, either:
219
+ - Use Prisma Accelerate: https://pris.ly/d/accelerate
220
+ - Use Driver Adapters: https://pris.ly/d/driver-adapters
221
+ `;
222
+ } else {
223
+ message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `' + runtime.prettyName + '`).'
224
+ }
225
+
226
+ message += `
227
+ If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report`
228
+
229
+ throw new Error(message)
230
+ }
231
+ })
232
+ }
233
+ }
234
+
235
+ exports.PrismaClient = PrismaClient
236
+
237
+ Object.assign(exports, Prisma)
@@ -0,0 +1,82 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ output = "./generated/law"
4
+ }
5
+
6
+ datasource db {
7
+ provider = "postgresql"
8
+ url = env("POSTGRES_PRISMA_URL_LAW")
9
+ directUrl = env("POSTGRES_URL_NON_POOLING_LAW")
10
+ schemas = ["public"]
11
+ }
12
+
13
+ /// Existing public tables (read-only recommended). Validate nullability via introspection.
14
+ model LawVersion {
15
+ id String @id
16
+ lawId String? @map("lawid")
17
+ versionNumber String? @map("versionnumber")
18
+ lawUrl String? @map("lawurl")
19
+ isLawVersionEffective Boolean? @map("islawversioneffective")
20
+ isAmendment Boolean? @map("isamendment")
21
+ fullLawId String? @map("fulllawid")
22
+ approvalDate DateTime? @map("approvaldate")
23
+ publicationDate DateTime? @map("publicationdate")
24
+ effectiveFrom DateTime? @map("effectivefrom")
25
+ effectiveUntil DateTime? @map("effectiveuntil")
26
+ author String?
27
+ fullLawHtml String? @map("fulllawhtml")
28
+ fullLaw String? @map("fulllaw")
29
+ legalAreas Json? @map("legalareas")
30
+ publishedIn Json? @map("publishedin")
31
+ relationships Json? @map("relationships")
32
+
33
+ attachments LawAttachment[]
34
+ paragraphs VersionParagraph[]
35
+
36
+ @@map("law_versions")
37
+ @@schema("public")
38
+ }
39
+
40
+ model LawAttachment {
41
+ id Int @id
42
+ name String?
43
+ attachmentId String? @map("attachmentid")
44
+ content String?
45
+ lawVersionId String @map("lawversionid")
46
+
47
+ lawVersion LawVersion @relation(fields: [lawVersionId], references: [id])
48
+
49
+ @@map("law_attachments")
50
+ @@schema("public")
51
+ }
52
+
53
+ model VersionParagraph {
54
+ id Int @id
55
+ paragraphId String? @map("paragraph_id")
56
+ versionId String @map("version_id")
57
+ sequenceNumber Int? @map("sequence_number")
58
+ text String?
59
+ fullText String? @map("full_text")
60
+ fullTextWithCitations String? @map("full_text_with_citations")
61
+ embedding Json?
62
+ partId String? @map("part_id")
63
+ partName String? @map("part_name")
64
+ chapterId String? @map("chapter_id")
65
+ chapterName String? @map("chapter_name")
66
+ divisionId String? @map("division_id")
67
+ divisionName String? @map("division_name")
68
+ sectionId String? @map("section_id")
69
+ sectionName String? @map("section_name")
70
+ paragraphPath String? @map("paragraph_path")
71
+ paragraphGroupName String? @map("paragraph_group_name")
72
+ isAmendment Boolean? @map("is_amendment")
73
+ validFrom DateTime? @map("valid_from")
74
+ validTo DateTime? @map("valid_to")
75
+
76
+ lawVersion LawVersion @relation(fields: [versionId], references: [id])
77
+
78
+ @@map("version_paragraphs")
79
+ @@schema("public")
80
+ }
81
+
82
+
@@ -0,0 +1,372 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "app"."Role" AS ENUM ('USER', 'ASSISTANT', 'SYSTEM');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "app"."FeedbackRating" AS ENUM ('LIKE', 'DISLIKE', 'NEUTRAL');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "app"."ReferenceType" AS ENUM ('LAW', 'CASE', 'REGULATION', 'DOCUMENT', 'OTHER');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "app"."ApprovalStatus" AS ENUM ('PENDING', 'APPROVED', 'REJECTED');
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "app"."Account" (
15
+ "id" TEXT NOT NULL,
16
+ "userId" TEXT NOT NULL,
17
+ "type" TEXT NOT NULL,
18
+ "provider" TEXT NOT NULL,
19
+ "providerAccountId" TEXT NOT NULL,
20
+ "refresh_token" TEXT,
21
+ "access_token" TEXT,
22
+ "expires_at" INTEGER,
23
+ "token_type" TEXT,
24
+ "scope" TEXT,
25
+ "id_token" TEXT,
26
+ "session_state" TEXT,
27
+
28
+ CONSTRAINT "Account_pkey" PRIMARY KEY ("id")
29
+ );
30
+
31
+ -- CreateTable
32
+ CREATE TABLE "app"."User" (
33
+ "id" TEXT NOT NULL,
34
+ "name" TEXT,
35
+ "email" TEXT,
36
+ "emailVerified" TIMESTAMP(3),
37
+ "image" TEXT,
38
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
39
+ "messageCount" INTEGER NOT NULL DEFAULT 100,
40
+ "agreedToTerms" BOOLEAN NOT NULL DEFAULT false,
41
+ "practiceArea" TEXT[],
42
+ "lawFirm" TEXT,
43
+ "yearsOfExperience" INTEGER,
44
+ "isApproved" BOOLEAN NOT NULL DEFAULT false,
45
+ "isRejected" BOOLEAN NOT NULL DEFAULT false,
46
+ "approvedAt" TIMESTAMP(3),
47
+ "rejectedAt" TIMESTAMP(3),
48
+ "approvedBy" TEXT,
49
+ "rejectedBy" TEXT,
50
+ "rejectionReason" TEXT,
51
+ "referralSource" TEXT,
52
+ "applicationText" TEXT,
53
+
54
+ CONSTRAINT "User_pkey" PRIMARY KEY ("id")
55
+ );
56
+
57
+ -- CreateTable
58
+ CREATE TABLE "app"."UserApprovalRequest" (
59
+ "id" TEXT NOT NULL,
60
+ "userId" TEXT NOT NULL,
61
+ "status" "app"."ApprovalStatus" NOT NULL DEFAULT 'PENDING',
62
+ "submittedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
63
+ "reviewedAt" TIMESTAMP(3),
64
+ "reviewedBy" TEXT,
65
+ "notes" TEXT,
66
+
67
+ CONSTRAINT "UserApprovalRequest_pkey" PRIMARY KEY ("id")
68
+ );
69
+
70
+ -- CreateTable
71
+ CREATE TABLE "app"."Conversation" (
72
+ "id" TEXT NOT NULL,
73
+ "name" TEXT NOT NULL,
74
+ "userId" TEXT NOT NULL,
75
+ "isShareable" BOOLEAN NOT NULL DEFAULT false,
76
+ "shareUrl" TEXT,
77
+ "sharedAt" TIMESTAMP(3),
78
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
79
+ "updatedAt" TIMESTAMP(3) NOT NULL,
80
+
81
+ CONSTRAINT "Conversation_pkey" PRIMARY KEY ("id")
82
+ );
83
+
84
+ -- CreateTable
85
+ CREATE TABLE "app"."Answer" (
86
+ "id" TEXT NOT NULL,
87
+ "conversationId" TEXT NOT NULL,
88
+ "messageId" TEXT NOT NULL,
89
+ "role" "app"."Role" NOT NULL,
90
+ "content" TEXT NOT NULL,
91
+ "question" TEXT,
92
+ "answer" TEXT,
93
+ "evaluation" TEXT,
94
+ "isWelcome" BOOLEAN NOT NULL DEFAULT false,
95
+ "processingTime" INTEGER,
96
+ "model" TEXT,
97
+ "userId" TEXT,
98
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
99
+ "updatedAt" TIMESTAMP(3) NOT NULL,
100
+
101
+ CONSTRAINT "Answer_pkey" PRIMARY KEY ("id")
102
+ );
103
+
104
+ -- CreateTable
105
+ CREATE TABLE "app"."AnswerMetrics" (
106
+ "id" TEXT NOT NULL,
107
+ "answerId" TEXT NOT NULL,
108
+ "apiCost" DOUBLE PRECISION,
109
+ "aiCost" DOUBLE PRECISION,
110
+ "ragCost" DOUBLE PRECISION,
111
+ "apiCalls" INTEGER,
112
+ "aiCalls" INTEGER,
113
+ "ragCalls" INTEGER,
114
+ "apiDuration" INTEGER,
115
+ "aiProvider" TEXT,
116
+ "aiModel" TEXT,
117
+ "aiProvidersUsed" TEXT[],
118
+ "aiModelsUsed" TEXT[],
119
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
120
+ "updatedAt" TIMESTAMP(3) NOT NULL,
121
+
122
+ CONSTRAINT "AnswerMetrics_pkey" PRIMARY KEY ("id")
123
+ );
124
+
125
+ -- CreateTable
126
+ CREATE TABLE "app"."Feedback" (
127
+ "id" TEXT NOT NULL,
128
+ "answerId" TEXT NOT NULL,
129
+ "rating" "app"."FeedbackRating" NOT NULL,
130
+ "feedbackTypes" TEXT[],
131
+ "customFeedback" TEXT,
132
+ "userId" TEXT NOT NULL,
133
+ "messageContent" TEXT,
134
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
135
+
136
+ CONSTRAINT "Feedback_pkey" PRIMARY KEY ("id")
137
+ );
138
+
139
+ -- CreateTable
140
+ CREATE TABLE "app"."Reference" (
141
+ "id" TEXT NOT NULL,
142
+ "answerId" TEXT NOT NULL,
143
+ "type" "app"."ReferenceType" NOT NULL,
144
+ "title" TEXT NOT NULL,
145
+ "reference" TEXT NOT NULL,
146
+ "summary" TEXT,
147
+ "url" TEXT,
148
+ "uuid" TEXT,
149
+ "relevance" DOUBLE PRECISION,
150
+ "citationNumber" INTEGER,
151
+ "metadata" JSONB,
152
+ "userId" TEXT,
153
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
154
+
155
+ CONSTRAINT "Reference_pkey" PRIMARY KEY ("id")
156
+ );
157
+
158
+ -- CreateTable
159
+ CREATE TABLE "app"."PageView" (
160
+ "id" TEXT NOT NULL,
161
+ "userId" TEXT,
162
+ "sessionId" TEXT NOT NULL,
163
+ "page" TEXT NOT NULL,
164
+ "path" TEXT NOT NULL,
165
+ "referrer" TEXT,
166
+ "userAgent" TEXT,
167
+ "ipAddress" TEXT,
168
+ "country" TEXT,
169
+ "city" TEXT,
170
+ "deviceType" TEXT,
171
+ "browser" TEXT,
172
+ "os" TEXT,
173
+ "screenSize" TEXT,
174
+ "language" TEXT,
175
+ "timeOnPage" INTEGER,
176
+ "isBounce" BOOLEAN NOT NULL DEFAULT true,
177
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
178
+
179
+ CONSTRAINT "PageView_pkey" PRIMARY KEY ("id")
180
+ );
181
+
182
+ -- CreateTable
183
+ CREATE TABLE "app"."Session" (
184
+ "id" TEXT NOT NULL,
185
+ "sessionId" TEXT NOT NULL,
186
+ "userId" TEXT,
187
+ "startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
188
+ "endedAt" TIMESTAMP(3),
189
+ "duration" INTEGER,
190
+
191
+ CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
192
+ );
193
+
194
+ -- CreateTable
195
+ CREATE TABLE "app"."AdminActionLog" (
196
+ "id" TEXT NOT NULL,
197
+ "action" TEXT NOT NULL,
198
+ "targetUserId" TEXT NOT NULL,
199
+ "adminEmail" TEXT NOT NULL,
200
+ "details" JSONB,
201
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
202
+
203
+ CONSTRAINT "AdminActionLog_pkey" PRIMARY KEY ("id")
204
+ );
205
+
206
+ -- CreateIndex
207
+ CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "app"."Account"("provider", "providerAccountId");
208
+
209
+ -- CreateIndex
210
+ CREATE UNIQUE INDEX "User_email_key" ON "app"."User"("email");
211
+
212
+ -- CreateIndex
213
+ CREATE UNIQUE INDEX "UserApprovalRequest_userId_key" ON "app"."UserApprovalRequest"("userId");
214
+
215
+ -- CreateIndex
216
+ CREATE INDEX "UserApprovalRequest_status_idx" ON "app"."UserApprovalRequest"("status");
217
+
218
+ -- CreateIndex
219
+ CREATE INDEX "UserApprovalRequest_submittedAt_idx" ON "app"."UserApprovalRequest"("submittedAt");
220
+
221
+ -- CreateIndex
222
+ CREATE INDEX "UserApprovalRequest_reviewedAt_idx" ON "app"."UserApprovalRequest"("reviewedAt");
223
+
224
+ -- CreateIndex
225
+ CREATE UNIQUE INDEX "Conversation_shareUrl_key" ON "app"."Conversation"("shareUrl");
226
+
227
+ -- CreateIndex
228
+ CREATE INDEX "Conversation_userId_idx" ON "app"."Conversation"("userId");
229
+
230
+ -- CreateIndex
231
+ CREATE INDEX "Conversation_createdAt_idx" ON "app"."Conversation"("createdAt");
232
+
233
+ -- CreateIndex
234
+ CREATE UNIQUE INDEX "Answer_messageId_key" ON "app"."Answer"("messageId");
235
+
236
+ -- CreateIndex
237
+ CREATE INDEX "Answer_conversationId_idx" ON "app"."Answer"("conversationId");
238
+
239
+ -- CreateIndex
240
+ CREATE INDEX "Answer_messageId_idx" ON "app"."Answer"("messageId");
241
+
242
+ -- CreateIndex
243
+ CREATE INDEX "Answer_role_idx" ON "app"."Answer"("role");
244
+
245
+ -- CreateIndex
246
+ CREATE INDEX "Answer_userId_idx" ON "app"."Answer"("userId");
247
+
248
+ -- CreateIndex
249
+ CREATE INDEX "Answer_createdAt_idx" ON "app"."Answer"("createdAt");
250
+
251
+ -- CreateIndex
252
+ CREATE UNIQUE INDEX "AnswerMetrics_answerId_key" ON "app"."AnswerMetrics"("answerId");
253
+
254
+ -- CreateIndex
255
+ CREATE INDEX "AnswerMetrics_answerId_idx" ON "app"."AnswerMetrics"("answerId");
256
+
257
+ -- CreateIndex
258
+ CREATE INDEX "AnswerMetrics_apiCost_idx" ON "app"."AnswerMetrics"("apiCost");
259
+
260
+ -- CreateIndex
261
+ CREATE INDEX "AnswerMetrics_apiDuration_idx" ON "app"."AnswerMetrics"("apiDuration");
262
+
263
+ -- CreateIndex
264
+ CREATE INDEX "AnswerMetrics_aiProvider_idx" ON "app"."AnswerMetrics"("aiProvider");
265
+
266
+ -- CreateIndex
267
+ CREATE INDEX "AnswerMetrics_createdAt_idx" ON "app"."AnswerMetrics"("createdAt");
268
+
269
+ -- CreateIndex
270
+ CREATE UNIQUE INDEX "Feedback_answerId_key" ON "app"."Feedback"("answerId");
271
+
272
+ -- CreateIndex
273
+ CREATE INDEX "Feedback_rating_idx" ON "app"."Feedback"("rating");
274
+
275
+ -- CreateIndex
276
+ CREATE INDEX "Feedback_userId_idx" ON "app"."Feedback"("userId");
277
+
278
+ -- CreateIndex
279
+ CREATE INDEX "Feedback_answerId_idx" ON "app"."Feedback"("answerId");
280
+
281
+ -- CreateIndex
282
+ CREATE INDEX "Reference_answerId_idx" ON "app"."Reference"("answerId");
283
+
284
+ -- CreateIndex
285
+ CREATE INDEX "Reference_type_idx" ON "app"."Reference"("type");
286
+
287
+ -- CreateIndex
288
+ CREATE INDEX "Reference_reference_idx" ON "app"."Reference"("reference");
289
+
290
+ -- CreateIndex
291
+ CREATE INDEX "Reference_userId_idx" ON "app"."Reference"("userId");
292
+
293
+ -- CreateIndex
294
+ CREATE INDEX "Reference_createdAt_idx" ON "app"."Reference"("createdAt");
295
+
296
+ -- CreateIndex
297
+ CREATE INDEX "PageView_userId_idx" ON "app"."PageView"("userId");
298
+
299
+ -- CreateIndex
300
+ CREATE INDEX "PageView_sessionId_idx" ON "app"."PageView"("sessionId");
301
+
302
+ -- CreateIndex
303
+ CREATE INDEX "PageView_page_idx" ON "app"."PageView"("page");
304
+
305
+ -- CreateIndex
306
+ CREATE INDEX "PageView_createdAt_idx" ON "app"."PageView"("createdAt");
307
+
308
+ -- CreateIndex
309
+ CREATE INDEX "PageView_country_idx" ON "app"."PageView"("country");
310
+
311
+ -- CreateIndex
312
+ CREATE INDEX "PageView_deviceType_idx" ON "app"."PageView"("deviceType");
313
+
314
+ -- CreateIndex
315
+ CREATE UNIQUE INDEX "Session_sessionId_key" ON "app"."Session"("sessionId");
316
+
317
+ -- CreateIndex
318
+ CREATE INDEX "Session_sessionId_idx" ON "app"."Session"("sessionId");
319
+
320
+ -- CreateIndex
321
+ CREATE INDEX "Session_userId_idx" ON "app"."Session"("userId");
322
+
323
+ -- CreateIndex
324
+ CREATE INDEX "Session_startedAt_idx" ON "app"."Session"("startedAt");
325
+
326
+ -- CreateIndex
327
+ CREATE INDEX "AdminActionLog_action_idx" ON "app"."AdminActionLog"("action");
328
+
329
+ -- CreateIndex
330
+ CREATE INDEX "AdminActionLog_targetUserId_idx" ON "app"."AdminActionLog"("targetUserId");
331
+
332
+ -- CreateIndex
333
+ CREATE INDEX "AdminActionLog_adminEmail_idx" ON "app"."AdminActionLog"("adminEmail");
334
+
335
+ -- CreateIndex
336
+ CREATE INDEX "AdminActionLog_createdAt_idx" ON "app"."AdminActionLog"("createdAt");
337
+
338
+ -- AddForeignKey
339
+ ALTER TABLE "app"."Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "app"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
340
+
341
+ -- AddForeignKey
342
+ ALTER TABLE "app"."UserApprovalRequest" ADD CONSTRAINT "UserApprovalRequest_userId_fkey" FOREIGN KEY ("userId") REFERENCES "app"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
343
+
344
+ -- AddForeignKey
345
+ ALTER TABLE "app"."Conversation" ADD CONSTRAINT "Conversation_userId_fkey" FOREIGN KEY ("userId") REFERENCES "app"."User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
346
+
347
+ -- AddForeignKey
348
+ ALTER TABLE "app"."Answer" ADD CONSTRAINT "Answer_conversationId_fkey" FOREIGN KEY ("conversationId") REFERENCES "app"."Conversation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
349
+
350
+ -- AddForeignKey
351
+ ALTER TABLE "app"."Answer" ADD CONSTRAINT "Answer_userId_fkey" FOREIGN KEY ("userId") REFERENCES "app"."User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
352
+
353
+ -- AddForeignKey
354
+ ALTER TABLE "app"."AnswerMetrics" ADD CONSTRAINT "AnswerMetrics_answerId_fkey" FOREIGN KEY ("answerId") REFERENCES "app"."Answer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
355
+
356
+ -- AddForeignKey
357
+ ALTER TABLE "app"."Feedback" ADD CONSTRAINT "Feedback_answerId_fkey" FOREIGN KEY ("answerId") REFERENCES "app"."Answer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
358
+
359
+ -- AddForeignKey
360
+ ALTER TABLE "app"."Feedback" ADD CONSTRAINT "Feedback_userId_fkey" FOREIGN KEY ("userId") REFERENCES "app"."User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
361
+
362
+ -- AddForeignKey
363
+ ALTER TABLE "app"."Reference" ADD CONSTRAINT "Reference_answerId_fkey" FOREIGN KEY ("answerId") REFERENCES "app"."Answer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
364
+
365
+ -- AddForeignKey
366
+ ALTER TABLE "app"."PageView" ADD CONSTRAINT "PageView_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "app"."Session"("sessionId") ON DELETE SET NULL ON UPDATE CASCADE;
367
+
368
+ -- AddForeignKey
369
+ ALTER TABLE "app"."PageView" ADD CONSTRAINT "PageView_userId_fkey" FOREIGN KEY ("userId") REFERENCES "app"."User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
370
+
371
+ -- AddForeignKey
372
+ ALTER TABLE "app"."Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "app"."User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,3 @@
1
+ # Please do not edit this file manually
2
+ # It should be added in your version-control system (e.g., Git)
3
+ provider = "postgresql"
package/prisma/seed.ts DELETED
File without changes