Skip to content

Commit 0e065e5

Browse files
authored
Remove drizzle relations (#26)
* feat: remove initial dirzzle relations * feat: remove initial dirzzle relations * chore: remove commented code * feat: remove userToOrg relations
1 parent 103c855 commit 0e065e5

File tree

10 files changed

+10
-137
lines changed

10 files changed

+10
-137
lines changed

bun.lockb

296 Bytes
Binary file not shown.

src/generated/graphql/schema.executable.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const spec_userOrganization = {
120120
}),
121121
description: undefined,
122122
extensions: {
123-
oid: "77872",
123+
oid: "92823",
124124
isTableLike: true,
125125
pg: {
126126
serviceName: "main",
@@ -200,7 +200,7 @@ const spec_downvote = {
200200
}),
201201
description: undefined,
202202
extensions: {
203-
oid: "78725",
203+
oid: "92888",
204204
isTableLike: true,
205205
pg: {
206206
serviceName: "main",
@@ -280,7 +280,7 @@ const spec_upvote = {
280280
}),
281281
description: undefined,
282282
extensions: {
283-
oid: "77850",
283+
oid: "92801",
284284
isTableLike: true,
285285
pg: {
286286
serviceName: "main",
@@ -360,7 +360,7 @@ const spec_organization = {
360360
}),
361361
description: undefined,
362362
extensions: {
363-
oid: "77812",
363+
oid: "92763",
364364
isTableLike: true,
365365
pg: {
366366
serviceName: "main",
@@ -452,7 +452,7 @@ const spec_comment = {
452452
}),
453453
description: undefined,
454454
extensions: {
455-
oid: "78467",
455+
oid: "92868",
456456
isTableLike: true,
457457
pg: {
458458
serviceName: "main",
@@ -556,7 +556,7 @@ const spec_post = {
556556
}),
557557
description: undefined,
558558
extensions: {
559-
oid: "77826",
559+
oid: "92777",
560560
isTableLike: true,
561561
pg: {
562562
serviceName: "main",
@@ -672,7 +672,7 @@ const spec_project = {
672672
}),
673673
description: undefined,
674674
extensions: {
675-
oid: "77836",
675+
oid: "92787",
676676
isTableLike: true,
677677
pg: {
678678
serviceName: "main",
@@ -776,7 +776,7 @@ const spec_user = {
776776
}),
777777
description: undefined,
778778
extensions: {
779-
oid: "77860",
779+
oid: "92811",
780780
isTableLike: true,
781781
pg: {
782782
serviceName: "main",

src/lib/drizzle/schema/comment.table.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { relations } from "drizzle-orm";
21
import { pgTable, text, uuid } from "drizzle-orm/pg-core";
32

43
import { defaultDate, defaultId } from "./constants";
@@ -27,20 +26,6 @@ export const comments = pgTable("comment", {
2726
updatedAt: defaultDate(),
2827
});
2928

30-
/**
31-
* Relations for the comment table.
32-
*/
33-
export const commentRelations = relations(comments, ({ one }) => ({
34-
post: one(posts, {
35-
fields: [comments.postId],
36-
references: [posts.id],
37-
}),
38-
user: one(users, {
39-
fields: [comments.userId],
40-
references: [users.id],
41-
}),
42-
}));
43-
4429
/**
4530
* Type helpers related to the comment table.
4631
*/

src/lib/drizzle/schema/downvote.table.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { relations } from "drizzle-orm";
21
import { pgTable, unique, uuid } from "drizzle-orm/pg-core";
32

43
import { defaultDate, defaultId } from "./constants";
@@ -30,20 +29,6 @@ export const downvotes = pgTable(
3029
(table) => [unique().on(table.postId, table.userId)]
3130
);
3231

33-
/**
34-
* Relations for the downvote table.
35-
*/
36-
export const downvoteRelations = relations(downvotes, ({ one }) => ({
37-
post: one(posts, {
38-
fields: [downvotes.postId],
39-
references: [posts.id],
40-
}),
41-
user: one(users, {
42-
fields: [downvotes.userId],
43-
references: [users.id],
44-
}),
45-
}));
46-
4732
/**
4833
* Type helpers related to the downvote table.
4934
*/

src/lib/drizzle/schema/organization.table.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { relations } from "drizzle-orm";
21
import { pgTable, text } from "drizzle-orm/pg-core";
32

43
import { defaultDate, defaultId } from "./constants";
5-
import { projects } from "./project.table";
6-
import { usersToOrganizations } from "./userToOrganization.table";
74

85
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
96

@@ -18,14 +15,6 @@ export const organizations = pgTable("organization", {
1815
updatedAt: defaultDate(),
1916
});
2017

21-
/**
22-
* Relations for the organization table.
23-
*/
24-
export const organizationRelations = relations(organizations, ({ many }) => ({
25-
projects: many(projects),
26-
users: many(usersToOrganizations),
27-
}));
28-
2918
/**
3019
* Type helpers related to the organization table.
3120
*/

src/lib/drizzle/schema/post.table.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import { relations } from "drizzle-orm";
21
import { pgTable, text, uuid } from "drizzle-orm/pg-core";
32

4-
import { comments } from "./comment.table";
53
import { defaultDate, defaultId } from "./constants";
6-
import { downvotes } from "./downvote.table";
74
import { projects } from "./project.table";
8-
import { upvotes } from "./upvote.table";
95
import { users } from "./user.table";
106

117
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
@@ -31,23 +27,6 @@ export const posts = pgTable("post", {
3127
updatedAt: defaultDate(),
3228
});
3329

34-
/**
35-
* Relations for the post table.
36-
*/
37-
export const postRelations = relations(posts, ({ one, many }) => ({
38-
project: one(projects, {
39-
fields: [posts.projectId],
40-
references: [projects.id],
41-
}),
42-
user: one(users, {
43-
fields: [posts.userId],
44-
references: [users.id],
45-
}),
46-
comments: many(comments),
47-
upvotes: many(upvotes),
48-
downvotes: many(downvotes),
49-
}));
50-
5130
/**
5231
* Type helpers related to the post table.
5332
*/

src/lib/drizzle/schema/project.table.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { relations } from "drizzle-orm";
21
import { pgTable, text, unique, uuid } from "drizzle-orm/pg-core";
32

43
import { defaultDate, defaultId } from "./constants";
54
import { organizations } from "./organization.table";
6-
import { posts } from "./post.table";
75

86
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
97

@@ -29,17 +27,6 @@ export const projects = pgTable(
2927
(table) => [unique().on(table.slug, table.organizationId)]
3028
);
3129

32-
/**
33-
* Relations for the project table.
34-
*/
35-
export const projectRelations = relations(projects, ({ one, many }) => ({
36-
organization: one(organizations, {
37-
fields: [projects.organizationId],
38-
references: [organizations.id],
39-
}),
40-
posts: many(posts),
41-
}));
42-
4330
/**
4431
* Type helpers related to the project table.
4532
*/

src/lib/drizzle/schema/upvote.table.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { relations } from "drizzle-orm";
21
import { pgTable, unique, uuid } from "drizzle-orm/pg-core";
32

43
import { defaultDate, defaultId } from "./constants";
@@ -30,20 +29,6 @@ export const upvotes = pgTable(
3029
(table) => [unique().on(table.postId, table.userId)]
3130
);
3231

33-
/**
34-
* Relations for the upvote table.
35-
*/
36-
export const upvoteRelations = relations(upvotes, ({ one }) => ({
37-
post: one(posts, {
38-
fields: [upvotes.postId],
39-
references: [posts.id],
40-
}),
41-
user: one(users, {
42-
fields: [upvotes.userId],
43-
references: [users.id],
44-
}),
45-
}));
46-
4732
/**
4833
* Type helpers related to the upvote table.
4934
*/

src/lib/drizzle/schema/user.table.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import { relations } from "drizzle-orm";
21
import { pgTable, text, uuid } from "drizzle-orm/pg-core";
32

4-
import { comments } from "./comment.table";
53
import { defaultDate, defaultId } from "./constants";
6-
import { downvotes } from "./downvote.table";
7-
import { posts } from "./post.table";
8-
import { upvotes } from "./upvote.table";
9-
import { usersToOrganizations } from "./userToOrganization.table";
104

115
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
126

@@ -24,17 +18,6 @@ export const users = pgTable("user", {
2418
updatedAt: defaultDate(),
2519
});
2620

27-
/**
28-
* Relations for the user table.
29-
*/
30-
export const userRelations = relations(users, ({ many }) => ({
31-
organizations: many(usersToOrganizations),
32-
posts: many(posts),
33-
comments: many(comments),
34-
upvotes: many(upvotes),
35-
downvotes: many(downvotes),
36-
}));
37-
3821
/**
3922
* Type helpers related to the user table.
4023
*/

src/lib/drizzle/schema/userToOrganization.table.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import {
2-
type InferInsertModel,
3-
type InferSelectModel,
4-
relations,
5-
} from "drizzle-orm";
61
import { pgTable, unique, uuid } from "drizzle-orm/pg-core";
72

83
import { defaultDate } from "./constants";
94
import { organizations } from "./organization.table";
105
import { users } from "./user.table";
116

7+
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
8+
129
/**
1310
* Users to organizations join table.
1411
*/
@@ -30,23 +27,6 @@ export const usersToOrganizations = pgTable(
3027
(table) => [unique().on(table.userId, table.organizationId)]
3128
);
3229

33-
/**
34-
* Relations for the users to organizations join table.
35-
*/
36-
export const usersToOrganizationsRelations = relations(
37-
usersToOrganizations,
38-
({ one }) => ({
39-
user: one(users, {
40-
fields: [usersToOrganizations.userId],
41-
references: [users.id],
42-
}),
43-
organization: one(organizations, {
44-
fields: [usersToOrganizations.organizationId],
45-
references: [organizations.id],
46-
}),
47-
})
48-
);
49-
5030
/**
5131
* Type helpers related to the users to organizations join table.
5232
*/

0 commit comments

Comments
 (0)