IssueAssignee table

This commit is contained in:
Oliver Bryan
2026-01-16 22:43:40 +00:00
parent 047332ce0b
commit 6ffb05eb3b
5 changed files with 854 additions and 2 deletions

View File

@@ -121,7 +121,6 @@ export const Issue = pgTable(
creatorId: integer()
.notNull()
.references(() => User.id),
assigneeId: integer().references(() => User.id),
sprintId: integer().references(() => Sprint.id),
},
@@ -132,6 +131,21 @@ export const Issue = pgTable(
],
);
export const IssueAssignee = pgTable(
"IssueAssignee",
{
id: integer().primaryKey().generatedAlwaysAsIdentity(),
issueId: integer()
.notNull()
.references(() => Issue.id, { onDelete: "cascade" }),
userId: integer()
.notNull()
.references(() => User.id, { onDelete: "cascade" }),
assignedAt: timestamp({ withTimezone: false }).defaultNow(),
},
(t) => [uniqueIndex("unique_issue_user").on(t.issueId, t.userId)],
);
// Zod schemas
export const UserSelectSchema = createSelectSchema(User);
export const UserInsertSchema = createInsertSchema(User);
@@ -151,6 +165,9 @@ export const SprintInsertSchema = createInsertSchema(Sprint);
export const IssueSelectSchema = createSelectSchema(Issue);
export const IssueInsertSchema = createInsertSchema(Issue);
export const IssueAssigneeSelectSchema = createSelectSchema(IssueAssignee);
export const IssueAssigneeInsertSchema = createInsertSchema(IssueAssignee);
export const SessionSelectSchema = createSelectSchema(Session);
export const SessionInsertSchema = createInsertSchema(Session);
@@ -178,6 +195,9 @@ export type SprintInsert = z.infer<typeof SprintInsertSchema>;
export type IssueRecord = z.infer<typeof IssueSelectSchema>;
export type IssueInsert = z.infer<typeof IssueInsertSchema>;
export type IssueAssigneeRecord = z.infer<typeof IssueAssigneeSelectSchema>;
export type IssueAssigneeInsert = z.infer<typeof IssueAssigneeInsertSchema>;
export type SessionRecord = z.infer<typeof SessionSelectSchema>;
export type SessionInsert = z.infer<typeof SessionInsertSchema>;
@@ -189,7 +209,7 @@ export type TimedSessionInsert = z.infer<typeof TimedSessionInsertSchema>;
export type IssueResponse = {
Issue: IssueRecord;
Creator: UserRecord;
Assignee: UserRecord | null;
Assignees: UserRecord[];
};
export type ProjectResponse = {