Persist issue read state and clear unread on open
This commit is contained in:
@@ -20,6 +20,7 @@ export { labels } from "./labels.js";
|
||||
export { issueLabels } from "./issue_labels.js";
|
||||
export { issueApprovals } from "./issue_approvals.js";
|
||||
export { issueComments } from "./issue_comments.js";
|
||||
export { issueReadStates } from "./issue_read_states.js";
|
||||
export { assets } from "./assets.js";
|
||||
export { issueAttachments } from "./issue_attachments.js";
|
||||
export { heartbeatRuns } from "./heartbeat_runs.js";
|
||||
|
||||
25
packages/db/src/schema/issue_read_states.ts
Normal file
25
packages/db/src/schema/issue_read_states.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { pgTable, uuid, text, timestamp, index, uniqueIndex } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
import { issues } from "./issues.js";
|
||||
|
||||
export const issueReadStates = pgTable(
|
||||
"issue_read_states",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id),
|
||||
issueId: uuid("issue_id").notNull().references(() => issues.id),
|
||||
userId: text("user_id").notNull(),
|
||||
lastReadAt: timestamp("last_read_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
companyIssueIdx: index("issue_read_states_company_issue_idx").on(table.companyId, table.issueId),
|
||||
companyUserIdx: index("issue_read_states_company_user_idx").on(table.companyId, table.userId),
|
||||
companyIssueUserUnique: uniqueIndex("issue_read_states_company_issue_user_idx").on(
|
||||
table.companyId,
|
||||
table.issueId,
|
||||
table.userId,
|
||||
),
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user