Add repair notes journal with running feed, visibility, and status tagging

New repair_note table for timestamped journal entries on tickets. Each
note captures author, content, visibility (internal or customer-facing),
and the ticket status at time of writing. Notes display as a running
feed on the ticket detail page with newest first. Internal notes have
a lock icon, customer-visible notes highlighted in blue. Supports add
and delete with appropriate permission gating.
This commit is contained in:
Ryan Moon
2026-03-29 10:27:39 -05:00
parent 01cff80f2b
commit 7eac03f6c2
11 changed files with 334 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
CREATE TYPE "repair_note_visibility" AS ENUM ('internal', 'customer');
CREATE TABLE "repair_note" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"repair_ticket_id" uuid NOT NULL REFERENCES "repair_ticket"("id"),
"author_id" uuid NOT NULL REFERENCES "user"("id"),
"author_name" varchar(255) NOT NULL,
"content" text NOT NULL,
"visibility" "repair_note_visibility" NOT NULL DEFAULT 'internal',
"ticket_status" "repair_ticket_status",
"created_at" timestamp with time zone NOT NULL DEFAULT now()
);

View File

@@ -127,6 +127,13 @@
"when": 1774770000000,
"tag": "0017_repair_in_transit_status",
"breakpoints": true
},
{
"idx": 18,
"version": "7",
"when": 1774780000000,
"tag": "0018_repair_notes",
"breakpoints": true
}
]
}

View File

@@ -140,6 +140,26 @@ export const repairLineItems = pgTable('repair_line_item', {
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
})
export const repairNoteVisibilityEnum = pgEnum('repair_note_visibility', ['internal', 'customer'])
export const repairNotes = pgTable('repair_note', {
id: uuid('id').primaryKey().defaultRandom(),
repairTicketId: uuid('repair_ticket_id')
.notNull()
.references(() => repairTickets.id),
authorId: uuid('author_id')
.notNull()
.references(() => users.id),
authorName: varchar('author_name', { length: 255 }).notNull(),
content: text('content').notNull(),
visibility: repairNoteVisibilityEnum('visibility').notNull().default('internal'),
ticketStatus: repairTicketStatusEnum('ticket_status'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
})
export type RepairNote = typeof repairNotes.$inferSelect
export type RepairNoteInsert = typeof repairNotes.$inferInsert
export const repairServiceTemplates = pgTable('repair_service_template', {
id: uuid('id').primaryKey().defaultRandom(),
companyId: uuid('company_id')