| 1 | import { createId } from '@paralleldrive/cuid2' |
| 2 | import { index, pgTable |
| 3 | import { members } |
| 4 | import { threadStatusEnum } |
| 5 | import { projects } |
| 6 | |
| 7 | export const threads = |
| 8 | 'threads', |
| 9 | { |
| 10 | id: text('id |
| 11 | .primaryKey() |
| 12 | .$defaultFn(() => |
| 13 | entityId: text('entity_id |
| 14 | projectId: text('project_id |
| 15 | .references(() => |
| 16 | .notNull(), |
| 17 | selectedText: text('selected_text |
| 18 | status: threadStatusEnum('status |
| 19 | createdByMemberId: text('created_by_member_id |
| 20 | () => members. |
| 21 | { |
| 22 | onDelete: 'set null', |
| 23 | } |
| 24 | ), |
| 25 | createdAt: timestamp('created_at |
| 26 | }, |
| 27 | (table) => |
| 28 | ) |
| 29 | |
| 30 | export const threadMessages = |
| 31 | id: text('id |
| 32 | .primaryKey() |
| 33 | .$defaultFn(() => |
| 34 | threadId: text('thread_id |
| 35 | .references(() => |
| 36 | .notNull(), |
| 37 | authorMemberId: text('author_member_id |
| 38 | onDelete: 'set null', |
| 39 | }), |
| 40 | body: text('body |
| 41 | createdAt: timestamp('created_at |
| 42 | }) |