/** * message 的 sys schema 表(编码规范 §7 / ADR-002)。 */ import { index, jsonb, text, timestamp } from 'drizzle-orm/pg-core'; import { sys } from '@shared/db.ts'; export const messageTable = sys.table( 'system_message', { id: text('id').primaryKey(), kind: text('kind').notNull(), staffId: text('staff_id').notNull(), positionId: text('position_id'), title: text('title').notNull(), body: text('body').notNull(), at: timestamp('at', { withTimezone: true }).notNull().defaultNow(), readAt: timestamp('read_at', { withTimezone: true }), /** 跨任务征答的卡体;驳回重答以 supersededBy 闭合原卡 —— 只增不改 */ card: jsonb('card'), answer: jsonb('answer'), eventRef: text('event_ref'), }, (t) => [index('message_staff_idx').on(t.staffId, t.at), index('message_unread_idx').on(t.staffId, t.readAt)], );