Skip to content

Commit c294019

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

File tree

2 files changed

+346
-136
lines changed

2 files changed

+346
-136
lines changed

database/migrations/relations.ts

Lines changed: 173 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@ import { relations } from "drizzle-orm/relations";
22
import {
33
neptunUser,
44
neptunUserOauthAccount,
5-
chatConversationMessage,
65
chatConversationFile,
76
chatConversation,
7+
chatConversationMessage,
8+
neptunUserFile,
89
githubAppInstallation,
9-
neptunContextFile,
1010
neptunContextImport,
1111
neptunUserProject,
12+
projectGithubInstallation,
13+
neptunContextFile,
1214
projectChatConversation,
15+
projectTemplateCollection,
16+
neptunUserTemplateCollection,
1317
projectUserFile,
14-
neptunUserFile,
18+
githubAppInstallationRepository,
19+
chatConversationShare,
20+
chatConversationShareWhitelistEntry,
1521
neptunUserTemplate,
22+
neptunUserWebauthnCredential,
1623
} from "./schema.js";
1724

1825
export const neptunUserOauthAccountRelations = relations(
@@ -27,79 +34,101 @@ export const neptunUserOauthAccountRelations = relations(
2734

2835
export const neptunUserRelations = relations(neptunUser, ({ many }) => ({
2936
neptunUserOauthAccounts: many(neptunUserOauthAccount),
30-
chatConversationMessages: many(chatConversationMessage),
3137
chatConversationFiles: many(chatConversationFile),
38+
chatConversationMessages: many(chatConversationMessage),
3239
chatConversations: many(chatConversation),
3340
githubAppInstallations: many(githubAppInstallation),
34-
neptunContextFiles: many(neptunContextFile),
3541
neptunContextImports: many(neptunContextImport),
42+
neptunContextFiles: many(neptunContextFile),
3643
neptunUserProjects: many(neptunUserProject),
37-
neptunUserTemplates: many(neptunUserTemplate),
3844
neptunUserFiles: many(neptunUserFile),
45+
neptunUserTemplateCollections: many(neptunUserTemplateCollection),
46+
chatConversationShareWhitelistEntries: many(
47+
chatConversationShareWhitelistEntry,
48+
),
49+
neptunUserTemplates: many(neptunUserTemplate),
50+
neptunUserWebauthnCredentials: many(neptunUserWebauthnCredential),
3951
}));
4052

41-
export const chatConversationMessageRelations = relations(
42-
chatConversationMessage,
43-
({ one }) => ({
44-
neptunUser: one(neptunUser, {
45-
fields: [chatConversationMessage.neptunUserId],
46-
references: [neptunUser.id],
47-
}),
48-
}),
49-
);
50-
5153
export const chatConversationFileRelations = relations(
5254
chatConversationFile,
5355
({ one }) => ({
5456
neptunUser: one(neptunUser, {
5557
fields: [chatConversationFile.neptunUserId],
5658
references: [neptunUser.id],
5759
}),
60+
chatConversation: one(chatConversation, {
61+
fields: [chatConversationFile.chatConversationId],
62+
references: [chatConversation.id],
63+
}),
64+
chatConversationMessage: one(chatConversationMessage, {
65+
fields: [chatConversationFile.chatConversationMessageId],
66+
references: [chatConversationMessage.id],
67+
}),
68+
neptunUserFile: one(neptunUserFile, {
69+
fields: [chatConversationFile.neptunUserFileId],
70+
references: [neptunUserFile.id],
71+
}),
5872
}),
5973
);
6074

6175
export const chatConversationRelations = relations(
6276
chatConversation,
63-
({ one }) => ({
77+
({ one, many }) => ({
78+
chatConversationFiles: many(chatConversationFile),
79+
chatConversationMessages: many(chatConversationMessage),
6480
neptunUser: one(neptunUser, {
6581
fields: [chatConversation.neptunUserId],
6682
references: [neptunUser.id],
6783
}),
84+
projectChatConversations: many(projectChatConversation),
85+
chatConversationShares: many(chatConversationShare),
6886
}),
6987
);
7088

71-
export const githubAppInstallationRelations = relations(
72-
githubAppInstallation,
73-
({ one }) => ({
89+
export const chatConversationMessageRelations = relations(
90+
chatConversationMessage,
91+
({ one, many }) => ({
92+
chatConversationFiles: many(chatConversationFile),
7493
neptunUser: one(neptunUser, {
75-
fields: [githubAppInstallation.neptunUserId],
94+
fields: [chatConversationMessage.neptunUserId],
7695
references: [neptunUser.id],
7796
}),
97+
chatConversation: one(chatConversation, {
98+
fields: [chatConversationMessage.chatConversationId],
99+
references: [chatConversation.id],
100+
}),
78101
}),
79102
);
80103

81-
export const neptunContextFileRelations = relations(
82-
neptunContextFile,
83-
({ one }) => ({
104+
export const neptunUserFileRelations = relations(
105+
neptunUserFile,
106+
({ one, many }) => ({
107+
chatConversationFiles: many(chatConversationFile),
108+
projectUserFiles: many(projectUserFile),
84109
neptunUser: one(neptunUser, {
85-
fields: [neptunContextFile.neptunUserId],
110+
fields: [neptunUserFile.neptunUserId],
86111
references: [neptunUser.id],
87112
}),
88-
neptunContextImport: one(neptunContextImport, {
89-
fields: [neptunContextFile.importId],
90-
references: [neptunContextImport.id],
91-
}),
92-
neptunUserProject: one(neptunUserProject, {
93-
fields: [neptunContextFile.projectId],
94-
references: [neptunUserProject.id],
113+
neptunUserTemplates: many(neptunUserTemplate),
114+
}),
115+
);
116+
117+
export const githubAppInstallationRelations = relations(
118+
githubAppInstallation,
119+
({ one, many }) => ({
120+
neptunUser: one(neptunUser, {
121+
fields: [githubAppInstallation.neptunUserId],
122+
references: [neptunUser.id],
95123
}),
124+
projectGithubInstallations: many(projectGithubInstallation),
125+
githubAppInstallationRepositories: many(githubAppInstallationRepository),
96126
}),
97127
);
98128

99129
export const neptunContextImportRelations = relations(
100130
neptunContextImport,
101131
({ one, many }) => ({
102-
neptunContextFiles: many(neptunContextFile),
103132
neptunUser: one(neptunUser, {
104133
fields: [neptunContextImport.neptunUserId],
105134
references: [neptunUser.id],
@@ -108,30 +137,95 @@ export const neptunContextImportRelations = relations(
108137
fields: [neptunContextImport.projectId],
109138
references: [neptunUserProject.id],
110139
}),
140+
neptunContextFiles: many(neptunContextFile),
111141
}),
112142
);
113143

114144
export const neptunUserProjectRelations = relations(
115145
neptunUserProject,
116146
({ one, many }) => ({
117-
neptunContextFiles: many(neptunContextFile),
118147
neptunContextImports: many(neptunContextImport),
148+
projectGithubInstallations: many(projectGithubInstallation),
149+
neptunContextFiles: many(neptunContextFile),
150+
projectChatConversations: many(projectChatConversation),
119151
neptunUser: one(neptunUser, {
120152
fields: [neptunUserProject.neptunUserId],
121153
references: [neptunUser.id],
122154
}),
123-
projectChatConversations: many(projectChatConversation),
155+
projectTemplateCollections: many(projectTemplateCollection),
124156
projectUserFiles: many(projectUserFile),
125157
}),
126158
);
127159

160+
export const projectGithubInstallationRelations = relations(
161+
projectGithubInstallation,
162+
({ one }) => ({
163+
neptunUserProject: one(neptunUserProject, {
164+
fields: [projectGithubInstallation.projectId],
165+
references: [neptunUserProject.id],
166+
}),
167+
githubAppInstallation: one(githubAppInstallation, {
168+
fields: [projectGithubInstallation.githubInstallationId],
169+
references: [githubAppInstallation.id],
170+
}),
171+
}),
172+
);
173+
174+
export const neptunContextFileRelations = relations(
175+
neptunContextFile,
176+
({ one }) => ({
177+
neptunUser: one(neptunUser, {
178+
fields: [neptunContextFile.neptunUserId],
179+
references: [neptunUser.id],
180+
}),
181+
neptunContextImport: one(neptunContextImport, {
182+
fields: [neptunContextFile.importId],
183+
references: [neptunContextImport.id],
184+
}),
185+
neptunUserProject: one(neptunUserProject, {
186+
fields: [neptunContextFile.projectId],
187+
references: [neptunUserProject.id],
188+
}),
189+
}),
190+
);
191+
128192
export const projectChatConversationRelations = relations(
129193
projectChatConversation,
130194
({ one }) => ({
131195
neptunUserProject: one(neptunUserProject, {
132196
fields: [projectChatConversation.projectId],
133197
references: [neptunUserProject.id],
134198
}),
199+
chatConversation: one(chatConversation, {
200+
fields: [projectChatConversation.chatConversationId],
201+
references: [chatConversation.id],
202+
}),
203+
}),
204+
);
205+
206+
export const projectTemplateCollectionRelations = relations(
207+
projectTemplateCollection,
208+
({ one }) => ({
209+
neptunUserProject: one(neptunUserProject, {
210+
fields: [projectTemplateCollection.projectId],
211+
references: [neptunUserProject.id],
212+
}),
213+
neptunUserTemplateCollection: one(neptunUserTemplateCollection, {
214+
fields: [projectTemplateCollection.templateCollectionId],
215+
references: [neptunUserTemplateCollection.id],
216+
}),
217+
}),
218+
);
219+
220+
export const neptunUserTemplateCollectionRelations = relations(
221+
neptunUserTemplateCollection,
222+
({ one, many }) => ({
223+
projectTemplateCollections: many(projectTemplateCollection),
224+
neptunUser: one(neptunUser, {
225+
fields: [neptunUserTemplateCollection.neptunUserId],
226+
references: [neptunUser.id],
227+
}),
228+
neptunUserTemplates: many(neptunUserTemplate),
135229
}),
136230
);
137231

@@ -149,15 +243,40 @@ export const projectUserFileRelations = relations(
149243
}),
150244
);
151245

152-
export const neptunUserFileRelations = relations(
153-
neptunUserFile,
246+
export const githubAppInstallationRepositoryRelations = relations(
247+
githubAppInstallationRepository,
248+
({ one }) => ({
249+
githubAppInstallation: one(githubAppInstallation, {
250+
fields: [githubAppInstallationRepository.githubAppInstallationId],
251+
references: [githubAppInstallation.id],
252+
}),
253+
}),
254+
);
255+
256+
export const chatConversationShareRelations = relations(
257+
chatConversationShare,
154258
({ one, many }) => ({
155-
projectUserFiles: many(projectUserFile),
156-
neptunUserTemplates: many(neptunUserTemplate),
259+
chatConversation: one(chatConversation, {
260+
fields: [chatConversationShare.chatConversationId],
261+
references: [chatConversation.id],
262+
}),
263+
chatConversationShareWhitelistEntries: many(
264+
chatConversationShareWhitelistEntry,
265+
),
266+
}),
267+
);
268+
269+
export const chatConversationShareWhitelistEntryRelations = relations(
270+
chatConversationShareWhitelistEntry,
271+
({ one }) => ({
157272
neptunUser: one(neptunUser, {
158-
fields: [neptunUserFile.neptunUserId],
273+
fields: [chatConversationShareWhitelistEntry.whitelistedNeptunUserId],
159274
references: [neptunUser.id],
160275
}),
276+
chatConversationShare: one(chatConversationShare, {
277+
fields: [chatConversationShareWhitelistEntry.chatConversationShareId],
278+
references: [chatConversationShare.id],
279+
}),
161280
}),
162281
);
163282

@@ -172,5 +291,19 @@ export const neptunUserTemplateRelations = relations(
172291
fields: [neptunUserTemplate.userFileId],
173292
references: [neptunUserFile.id],
174293
}),
294+
neptunUserTemplateCollection: one(neptunUserTemplateCollection, {
295+
fields: [neptunUserTemplate.templateCollectionId],
296+
references: [neptunUserTemplateCollection.id],
297+
}),
298+
}),
299+
);
300+
301+
export const neptunUserWebauthnCredentialRelations = relations(
302+
neptunUserWebauthnCredential,
303+
({ one }) => ({
304+
neptunUser: one(neptunUser, {
305+
fields: [neptunUserWebauthnCredential.neptunUserId],
306+
references: [neptunUser.id],
307+
}),
175308
}),
176309
);

0 commit comments

Comments
 (0)