Skip to content

Commit f76996b

Browse files
committed
[create-pull-request] automated change
1 parent 1d80875 commit f76996b

File tree

2 files changed

+39
-189
lines changed

2 files changed

+39
-189
lines changed

database/migrations/relations.ts

Lines changed: 18 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,16 @@ import {
33
neptunUser,
44
neptunUserOauthAccount,
55
chatConversationMessage,
6-
chatConversation,
76
chatConversationFile,
8-
neptunUserFile,
7+
chatConversation,
98
githubAppInstallation,
10-
githubAppInstallationRepository,
119
neptunContextFile,
1210
neptunContextImport,
1311
neptunUserProject,
1412
projectChatConversation,
15-
projectGithubInstallation,
16-
projectTemplateCollection,
17-
neptunUserTemplateCollection,
1813
projectUserFile,
14+
neptunUserFile,
1915
neptunUserTemplate,
20-
chatConversationShare,
21-
chatConversationShareWhitelistEntry,
2216
} from "./schema.js";
2317

2418
export const neptunUserOauthAccountRelations = relations(
@@ -42,38 +36,15 @@ export const neptunUserRelations = relations(neptunUser, ({ many }) => ({
4236
neptunUserProjects: many(neptunUserProject),
4337
neptunUserTemplates: many(neptunUserTemplate),
4438
neptunUserFiles: many(neptunUserFile),
45-
neptunUserTemplateCollections: many(neptunUserTemplateCollection),
46-
chatConversationShareWhitelistEntries: many(
47-
chatConversationShareWhitelistEntry,
48-
),
4939
}));
5040

5141
export const chatConversationMessageRelations = relations(
5242
chatConversationMessage,
53-
({ one, many }) => ({
43+
({ one }) => ({
5444
neptunUser: one(neptunUser, {
5545
fields: [chatConversationMessage.neptunUserId],
5646
references: [neptunUser.id],
5747
}),
58-
chatConversation: one(chatConversation, {
59-
fields: [chatConversationMessage.chatConversationId],
60-
references: [chatConversation.id],
61-
}),
62-
chatConversationFiles: many(chatConversationFile),
63-
}),
64-
);
65-
66-
export const chatConversationRelations = relations(
67-
chatConversation,
68-
({ one, many }) => ({
69-
chatConversationMessages: many(chatConversationMessage),
70-
chatConversationFiles: many(chatConversationFile),
71-
neptunUser: one(neptunUser, {
72-
fields: [chatConversation.neptunUserId],
73-
references: [neptunUser.id],
74-
}),
75-
projectChatConversations: many(projectChatConversation),
76-
chatConversationShares: many(chatConversationShare),
7748
}),
7849
);
7950

@@ -84,53 +55,26 @@ export const chatConversationFileRelations = relations(
8455
fields: [chatConversationFile.neptunUserId],
8556
references: [neptunUser.id],
8657
}),
87-
chatConversation: one(chatConversation, {
88-
fields: [chatConversationFile.chatConversationId],
89-
references: [chatConversation.id],
90-
}),
91-
chatConversationMessage: one(chatConversationMessage, {
92-
fields: [chatConversationFile.chatConversationMessageId],
93-
references: [chatConversationMessage.id],
94-
}),
95-
neptunUserFile: one(neptunUserFile, {
96-
fields: [chatConversationFile.neptunUserFileId],
97-
references: [neptunUserFile.id],
98-
}),
9958
}),
10059
);
10160

102-
export const neptunUserFileRelations = relations(
103-
neptunUserFile,
104-
({ one, many }) => ({
105-
chatConversationFiles: many(chatConversationFile),
106-
projectUserFiles: many(projectUserFile),
107-
neptunUserTemplates: many(neptunUserTemplate),
61+
export const chatConversationRelations = relations(
62+
chatConversation,
63+
({ one }) => ({
10864
neptunUser: one(neptunUser, {
109-
fields: [neptunUserFile.neptunUserId],
65+
fields: [chatConversation.neptunUserId],
11066
references: [neptunUser.id],
11167
}),
11268
}),
11369
);
11470

11571
export const githubAppInstallationRelations = relations(
11672
githubAppInstallation,
117-
({ one, many }) => ({
73+
({ one }) => ({
11874
neptunUser: one(neptunUser, {
11975
fields: [githubAppInstallation.neptunUserId],
12076
references: [neptunUser.id],
12177
}),
122-
githubAppInstallationRepositories: many(githubAppInstallationRepository),
123-
projectGithubInstallations: many(projectGithubInstallation),
124-
}),
125-
);
126-
127-
export const githubAppInstallationRepositoryRelations = relations(
128-
githubAppInstallationRepository,
129-
({ one }) => ({
130-
githubAppInstallation: one(githubAppInstallation, {
131-
fields: [githubAppInstallationRepository.githubAppInstallationId],
132-
references: [githubAppInstallation.id],
133-
}),
13478
}),
13579
);
13680

@@ -177,8 +121,6 @@ export const neptunUserProjectRelations = relations(
177121
references: [neptunUser.id],
178122
}),
179123
projectChatConversations: many(projectChatConversation),
180-
projectGithubInstallations: many(projectGithubInstallation),
181-
projectTemplateCollections: many(projectTemplateCollection),
182124
projectUserFiles: many(projectUserFile),
183125
}),
184126
);
@@ -190,67 +132,35 @@ export const projectChatConversationRelations = relations(
190132
fields: [projectChatConversation.projectId],
191133
references: [neptunUserProject.id],
192134
}),
193-
chatConversation: one(chatConversation, {
194-
fields: [projectChatConversation.chatConversationId],
195-
references: [chatConversation.id],
196-
}),
197135
}),
198136
);
199137

200-
export const projectGithubInstallationRelations = relations(
201-
projectGithubInstallation,
202-
({ one }) => ({
203-
neptunUserProject: one(neptunUserProject, {
204-
fields: [projectGithubInstallation.projectId],
205-
references: [neptunUserProject.id],
206-
}),
207-
githubAppInstallation: one(githubAppInstallation, {
208-
fields: [projectGithubInstallation.githubInstallationId],
209-
references: [githubAppInstallation.id],
210-
}),
211-
}),
212-
);
213-
214-
export const projectTemplateCollectionRelations = relations(
215-
projectTemplateCollection,
138+
export const projectUserFileRelations = relations(
139+
projectUserFile,
216140
({ one }) => ({
217141
neptunUserProject: one(neptunUserProject, {
218-
fields: [projectTemplateCollection.projectId],
142+
fields: [projectUserFile.projectId],
219143
references: [neptunUserProject.id],
220144
}),
221-
neptunUserTemplateCollection: one(neptunUserTemplateCollection, {
222-
fields: [projectTemplateCollection.templateCollectionId],
223-
references: [neptunUserTemplateCollection.id],
145+
neptunUserFile: one(neptunUserFile, {
146+
fields: [projectUserFile.userFileId],
147+
references: [neptunUserFile.id],
224148
}),
225149
}),
226150
);
227151

228-
export const neptunUserTemplateCollectionRelations = relations(
229-
neptunUserTemplateCollection,
152+
export const neptunUserFileRelations = relations(
153+
neptunUserFile,
230154
({ one, many }) => ({
231-
projectTemplateCollections: many(projectTemplateCollection),
155+
projectUserFiles: many(projectUserFile),
232156
neptunUserTemplates: many(neptunUserTemplate),
233157
neptunUser: one(neptunUser, {
234-
fields: [neptunUserTemplateCollection.neptunUserId],
158+
fields: [neptunUserFile.neptunUserId],
235159
references: [neptunUser.id],
236160
}),
237161
}),
238162
);
239163

240-
export const projectUserFileRelations = relations(
241-
projectUserFile,
242-
({ one }) => ({
243-
neptunUserProject: one(neptunUserProject, {
244-
fields: [projectUserFile.projectId],
245-
references: [neptunUserProject.id],
246-
}),
247-
neptunUserFile: one(neptunUserFile, {
248-
fields: [projectUserFile.userFileId],
249-
references: [neptunUserFile.id],
250-
}),
251-
}),
252-
);
253-
254164
export const neptunUserTemplateRelations = relations(
255165
neptunUserTemplate,
256166
({ one }) => ({
@@ -262,36 +172,5 @@ export const neptunUserTemplateRelations = relations(
262172
fields: [neptunUserTemplate.userFileId],
263173
references: [neptunUserFile.id],
264174
}),
265-
neptunUserTemplateCollection: one(neptunUserTemplateCollection, {
266-
fields: [neptunUserTemplate.templateCollectionId],
267-
references: [neptunUserTemplateCollection.id],
268-
}),
269-
}),
270-
);
271-
272-
export const chatConversationShareRelations = relations(
273-
chatConversationShare,
274-
({ one, many }) => ({
275-
chatConversation: one(chatConversation, {
276-
fields: [chatConversationShare.chatConversationId],
277-
references: [chatConversation.id],
278-
}),
279-
chatConversationShareWhitelistEntries: many(
280-
chatConversationShareWhitelistEntry,
281-
),
282-
}),
283-
);
284-
285-
export const chatConversationShareWhitelistEntryRelations = relations(
286-
chatConversationShareWhitelistEntry,
287-
({ one }) => ({
288-
neptunUser: one(neptunUser, {
289-
fields: [chatConversationShareWhitelistEntry.whitelistedNeptunUserId],
290-
references: [neptunUser.id],
291-
}),
292-
chatConversationShare: one(chatConversationShare, {
293-
fields: [chatConversationShareWhitelistEntry.chatConversationShareId],
294-
references: [chatConversationShare.id],
295-
}),
296175
}),
297176
);

database/migrations/schema.ts

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ import {
1212
} from "drizzle-orm/pg-core";
1313

1414
export const aiModelEnum = pgEnum("ai_model_enum", [
15+
"google/gemma-2-27b-it",
1516
"qwen/Qwen2.5-72B-Instruct",
1617
"qwen/Qwen2.5-Coder-32B-Instruct",
1718
"deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
18-
"meta-llama/Llama-3.3-70B-Instruct",
1919
"mistralai/Mistral-Nemo-Instruct-2407",
2020
"mistralai/Mistral-7B-Instruct-v0.3",
2121
"microsoft/Phi-3-mini-4k-instruct",
22-
"google/gemma-2-27b-it",
22+
"cloudflare/llama-3.3-70b-instruct-fp8-fast",
23+
"openrouter/gemini-2.0-pro-exp-02-05",
24+
"openrouter/deepseek-chat",
25+
"openrouter/llama-3.3-70b-instruct",
26+
"openrouter/llama-3.1-nemotron-70b-instruct",
2327
]);
2428
export const chatConversationMessageActorEnum = pgEnum(
2529
"chat_conversation_message_actor_enum",
@@ -105,9 +109,7 @@ export const chatConversationMessage = pgTable("chat_conversation_message", {
105109
neptunUserId: integer("neptun_user_id")
106110
.notNull()
107111
.references(() => neptunUser.id, { onDelete: "cascade" }),
108-
chatConversationId: integer("chat_conversation_id")
109-
.notNull()
110-
.references(() => chatConversation.id, { onDelete: "cascade" }),
112+
chatConversationId: integer("chat_conversation_id").notNull(),
111113
});
112114

113115
export const chatConversationFile = pgTable("chat_conversation_file", {
@@ -117,15 +119,9 @@ export const chatConversationFile = pgTable("chat_conversation_file", {
117119
neptunUserId: integer("neptun_user_id")
118120
.notNull()
119121
.references(() => neptunUser.id, { onDelete: "cascade" }),
120-
chatConversationId: integer("chat_conversation_id")
121-
.notNull()
122-
.references(() => chatConversation.id, { onDelete: "cascade" }),
123-
chatConversationMessageId: integer("chat_conversation_message_id")
124-
.notNull()
125-
.references(() => chatConversationMessage.id, { onDelete: "cascade" }),
126-
neptunUserFileId: integer("neptun_user_file_id")
127-
.notNull()
128-
.references(() => neptunUserFile.id, { onDelete: "cascade" }),
122+
chatConversationId: integer("chat_conversation_id").notNull(),
123+
chatConversationMessageId: integer("chat_conversation_message_id").notNull(),
124+
neptunUserFileId: integer("neptun_user_file_id").notNull(),
129125
});
130126

131127
export const chatConversation = pgTable("chat_conversation", {
@@ -175,9 +171,7 @@ export const githubAppInstallationRepository = pgTable(
175171
).notNull(),
176172
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
177173
updatedAt: timestamp("updated_at", { mode: "string" }).defaultNow(),
178-
githubAppInstallationId: integer("github_app_installation_id")
179-
.notNull()
180-
.references(() => githubAppInstallation.id, { onDelete: "cascade" }),
174+
githubAppInstallationId: integer("github_app_installation_id").notNull(),
181175
},
182176
);
183177

@@ -242,36 +236,24 @@ export const projectChatConversation = pgTable("project_chat_conversation", {
242236
projectId: integer("project_id")
243237
.notNull()
244238
.references(() => neptunUserProject.id, { onDelete: "cascade" }),
245-
chatConversationId: integer("chat_conversation_id")
246-
.notNull()
247-
.references(() => chatConversation.id, { onDelete: "cascade" }),
239+
chatConversationId: integer("chat_conversation_id").notNull(),
248240
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
249241
});
250242

251243
export const projectGithubInstallation = pgTable(
252244
"project_github_installation",
253245
{
254-
projectId: integer("project_id")
255-
.notNull()
256-
.references(() => neptunUserProject.id, { onDelete: "cascade" }),
257-
githubInstallationId: integer("github_installation_id")
258-
.notNull()
259-
.references(() => githubAppInstallation.id, { onDelete: "cascade" }),
246+
projectId: integer("project_id").notNull(),
247+
githubInstallationId: integer("github_installation_id").notNull(),
260248
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
261249
},
262250
);
263251

264252
export const projectTemplateCollection = pgTable(
265253
"project_template_collection",
266254
{
267-
projectId: integer("project_id")
268-
.notNull()
269-
.references(() => neptunUserProject.id, { onDelete: "cascade" }),
270-
templateCollectionId: integer("template_collection_id")
271-
.notNull()
272-
.references(() => neptunUserTemplateCollection.id, {
273-
onDelete: "cascade",
274-
}),
255+
projectId: integer("project_id").notNull(),
256+
templateCollectionId: integer("template_collection_id").notNull(),
275257
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
276258
},
277259
);
@@ -295,10 +277,7 @@ export const neptunUserTemplate = pgTable("neptun_user_template", {
295277
neptunUserId: integer("neptun_user_id")
296278
.notNull()
297279
.references(() => neptunUser.id, { onDelete: "cascade" }),
298-
templateCollectionId: integer("template_collection_id").references(
299-
() => neptunUserTemplateCollection.id,
300-
{ onDelete: "cascade" },
301-
),
280+
templateCollectionId: integer("template_collection_id"),
302281
userFileId: integer("user_file_id").references(() => neptunUserFile.id, {
303282
onDelete: "cascade",
304283
}),
@@ -314,9 +293,7 @@ export const chatConversationShare = pgTable(
314293
hashedPassword: text("hashed_password"),
315294
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
316295
updatedAt: timestamp("updated_at", { mode: "string" }).defaultNow(),
317-
chatConversationId: integer("chat_conversation_id")
318-
.notNull()
319-
.references(() => chatConversation.id, { onDelete: "cascade" }),
296+
chatConversationId: integer("chat_conversation_id").notNull(),
320297
},
321298
(table) => {
322299
return {
@@ -353,9 +330,7 @@ export const neptunUserTemplateCollection = pgTable(
353330
shareId: uuid("share_id").defaultRandom().notNull(),
354331
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
355332
updatedAt: timestamp("updated_at", { mode: "string" }).defaultNow(),
356-
neptunUserId: integer("neptun_user_id")
357-
.notNull()
358-
.references(() => neptunUser.id, { onDelete: "cascade" }),
333+
neptunUserId: integer("neptun_user_id").notNull(),
359334
},
360335
(table) => {
361336
return {
@@ -372,11 +347,7 @@ export const chatConversationShareWhitelistEntry = pgTable(
372347
id: serial("id").primaryKey().notNull(),
373348
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
374349
updatedAt: timestamp("updated_at", { mode: "string" }).defaultNow(),
375-
whitelistedNeptunUserId: integer("whitelisted_neptun_user_id")
376-
.notNull()
377-
.references(() => neptunUser.id, { onDelete: "cascade" }),
378-
chatConversationShareId: integer("chat_conversation_share_id")
379-
.notNull()
380-
.references(() => chatConversationShare.id, { onDelete: "cascade" }),
350+
whitelistedNeptunUserId: integer("whitelisted_neptun_user_id").notNull(),
351+
chatConversationShareId: integer("chat_conversation_share_id").notNull(),
381352
},
382353
);

0 commit comments

Comments
 (0)