swadhinbiswas feat: OpenCodeHub v1.1.0 - Enterprise Features & Storage Adapters · 2/15/2026
719a1cb
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
import { relations } from "drizzle-orm";
import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { repositories } from "./repositories";
import { issues } from "./issues";
import { pullRequests } from "./pull-requests";
import { users } from "./users";
export const projects = pgTable("projects", {
id: text("id").primaryKey(),
repositoryId: text("repository_id")
.notNull()
.references(() => repositories.id, { onDelete: "cascade" }),
name: text("name").notNull(),
description: text("description"),
number: integer("number").notNull(),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
creatorId: text("creator_id")
.notNull()
.references(() => users.id),
});
export const projectColumns = pgTable("project_columns", {
id: text("id").primaryKey(),
projectId: text("project_id")
.notNull()
.references(() => projects.id, { onDelete: "cascade" }),
name: text("name").notNull(),
order: integer("order").notNull(), // Position in the board
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
});
export const projectCards = pgTable("project_cards", {
id: text("id").primaryKey(),
columnId: text("column_id")
.notNull()
.references(() => projectColumns.id, { onDelete: "cascade" }),
contentId: text("content_id"), // ID of issue or PR (optional if just a note)
contentType: text("content_type"), // 'issue' | 'pull_request' | 'note'
note: text("note"), // For cards that aren't issues/PRs
order: integer("order").notNull(), // Position in the column
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
creatorId: text("creator_id")
.notNull()
.references(() => users.id),
});
// Relations
export const projectsRelations = relations(projects, ({ one, many }) => ({
repository: one(repositories, {
fields: [projects.repositoryId],
references: [repositories.id],
}),
creator: one(users, {
fields: [projects.creatorId],
references: [users.id],
}),
columns: many(projectColumns),
}));
export const projectColumnsRelations = relations(projectColumns, ({ one, many }) => ({
project: one(projects, {
fields: [projectColumns.projectId],
references: [projects.id],
}),
cards: many(projectCards),
}));
export const projectCardsRelations = relations(projectCards, ({ one }) => ({
column: one(projectColumns, {
fields: [projectCards.columnId],
references: [projectColumns.id],
}),
creator: one(users, {
fields: [projectCards.creatorId],
references: [users.id],
}),
}));