| 1 | import { createId } from '@paralleldrive/cuid2' |
| 2 | import { index, pgTable |
| 3 | import { members } |
| 4 | import { changeRequestStatusEnum, statusEnum |
| 5 | import { media } |
| 6 | import { projects } |
| 7 | |
| 8 | export const requirements = |
| 9 | 'requirements', |
| 10 | { |
| 11 | id: text('id |
| 12 | .primaryKey() |
| 13 | .$defaultFn(() => |
| 14 | projectId: text('project_id |
| 15 | .references(() => |
| 16 | .notNull(), |
| 17 | authorId: text('author_id |
| 18 | onDelete: 'set null', |
| 19 | }), |
| 20 | slug: text('slug |
| 21 | title: text('title |
| 22 | body: text('body |
| 23 | status: statusEnum('status |
| 24 | createdAt: timestamp('created_at |
| 25 | updatedAt: timestamp('updated_at |
| 26 | .defaultNow() |
| 27 | .$onUpdate(() => |
| 28 | .notNull(), |
| 29 | }, |
| 30 | (t) => |
| 31 | unique().on(t |
| 32 | index('requirements_project_id_idx'). |
| 33 | ] |
| 34 | ) |
| 35 | |
| 36 | export const requirementRecipients = |
| 37 | id: text('id |
| 38 | .primaryKey() |
| 39 | .$defaultFn(() => |
| 40 | requirementId: text('requirement_id |
| 41 | .references(() => |
| 42 | .notNull(), |
| 43 | clientMemberId: text('client_member_id |
| 44 | .references(() => |
| 45 | .notNull(), |
| 46 | sentAt: timestamp('sent_at |
| 47 | }) |
| 48 | |
| 49 | export const requirementSignatures = |
| 50 | id: text('id |
| 51 | .primaryKey() |
| 52 | .$defaultFn(() => |
| 53 | requirementId: text('requirement_id |
| 54 | .references(() => |
| 55 | .notNull(), |
| 56 | clientMemberId: text('client_member_id |
| 57 | .references(() => |
| 58 | .notNull(), |
| 59 | signedAt: timestamp('signed_at |
| 60 | mediaId: text('media_id |
| 61 | onDelete: 'set null', |
| 62 | }), |
| 63 | }) |
| 64 | |
| 65 | export const requirementChangeRequests = |
| 66 | 'requirement_change_requests', |
| 67 | { |
| 68 | id: text('id |
| 69 | .primaryKey() |
| 70 | .$defaultFn(() => |
| 71 | requirementId: text('requirement_id |
| 72 | .references(() => |
| 73 | .notNull(), |
| 74 | requestedByMemberId: text('requested_by_member_id |
| 75 | () => members. |
| 76 | { onDelete: 'set null' |
| 77 | ), |
| 78 | description: text('description |
| 79 | referencedThreadIds: text('referenced_thread_ids |
| 80 | status: changeRequestStatusEnum('status |
| 81 | createdAt: timestamp('created_at |
| 82 | resolvedAt: timestamp('resolved_at |
| 83 | } |
| 84 | ) |