added Sprint table

This commit is contained in:
Oliver Bryan
2026-01-12 00:53:40 +00:00
parent 5609f76a91
commit e967c4deda
5 changed files with 776 additions and 0 deletions

View File

@@ -26,6 +26,8 @@ export type {
ProjectResponse,
SessionInsert,
SessionRecord,
SprintInsert,
SprintRecord,
TimedSessionInsert,
TimedSessionRecord,
TimerState,
@@ -33,6 +35,7 @@ export type {
UserRecord,
} from "./schema";
export {
DEFAULT_SPRINT_COLOUR,
DEFAULT_STATUS_COLOUR,
DEFAULT_STATUS_COLOURS,
Issue,
@@ -50,6 +53,9 @@ export {
Session,
SessionInsertSchema,
SessionSelectSchema,
Sprint,
SprintInsertSchema,
SprintSelectSchema,
TimedSession,
TimedSessionInsertSchema,
TimedSessionSelectSchema,

View File

@@ -13,6 +13,8 @@ import {
USER_USERNAME_MAX_LENGTH,
} from "./constants";
export const DEFAULT_SPRINT_COLOUR = "#a1a1a1";
export const DEFAULT_STATUS_COLOUR = "#a1a1a1";
export const DEFAULT_STATUS_COLOURS: Record<string, string> = {
@@ -69,6 +71,18 @@ export const Project = pgTable("Project", {
.references(() => User.id),
});
export const Sprint = pgTable("Sprint", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
projectId: integer()
.notNull()
.references(() => Project.id),
name: varchar({ length: 64 }).notNull(),
color: varchar({ length: 7 }).notNull().default(DEFAULT_SPRINT_COLOUR),
startDate: timestamp({ withTimezone: false }).notNull(),
endDate: timestamp({ withTimezone: false }).notNull(),
createdAt: timestamp({ withTimezone: false }).defaultNow(),
});
export const Session = pgTable("Session", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
userId: integer()
@@ -108,6 +122,8 @@ export const Issue = pgTable(
.notNull()
.references(() => User.id),
assigneeId: integer().references(() => User.id),
sprintId: integer().references(() => Sprint.id),
},
(t) => [
// ensures unique numbers per project
@@ -129,6 +145,9 @@ export const OrganisationMemberInsertSchema = createInsertSchema(OrganisationMem
export const ProjectSelectSchema = createSelectSchema(Project);
export const ProjectInsertSchema = createInsertSchema(Project);
export const SprintSelectSchema = createSelectSchema(Sprint);
export const SprintInsertSchema = createInsertSchema(Sprint);
export const IssueSelectSchema = createSelectSchema(Issue);
export const IssueInsertSchema = createInsertSchema(Issue);
@@ -153,6 +172,9 @@ export type OrganisationMemberInsert = z.infer<typeof OrganisationMemberInsertSc
export type ProjectRecord = z.infer<typeof ProjectSelectSchema>;
export type ProjectInsert = z.infer<typeof ProjectInsertSchema>;
export type SprintRecord = z.infer<typeof SprintSelectSchema>;
export type SprintInsert = z.infer<typeof SprintInsertSchema>;
export type IssueRecord = z.infer<typeof IssueSelectSchema>;
export type IssueInsert = z.infer<typeof IssueInsertSchema>;