| 1 | import { createId } from '@paralleldrive/cuid2' |
| 2 | import { |
| 3 | index, |
| 4 | integer, |
| 5 | numeric, |
| 6 | pgTable, |
| 7 | text, |
| 8 | timestamp, |
| 9 | } from 'drizzle-orm/pg-core' |
| 10 | import { members } |
| 11 | import { statusEnum } |
| 12 | import { media } |
| 13 | import { projects } |
| 14 | |
| 15 | export const proposals = |
| 16 | 'proposals', |
| 17 | { |
| 18 | id: text('id |
| 19 | .primaryKey() |
| 20 | .$defaultFn(() => |
| 21 | projectId: text('project_id |
| 22 | .references(() => |
| 23 | .notNull(), |
| 24 | authorId: text('author_id |
| 25 | onDelete: 'set null', |
| 26 | }), |
| 27 | title: text('title |
| 28 | slug: text('slug |
| 29 | body: text('body |
| 30 | terms: text('terms |
| 31 | status: statusEnum('status |
| 32 | validUntil: timestamp('valid_until |
| 33 | currency: text('currency |
| 34 | totalAmount: numeric('total_amount |
| 35 | .default('0') |
| 36 | .notNull(), |
| 37 | createdAt: timestamp('created_at |
| 38 | updatedAt: timestamp('updated_at |
| 39 | .defaultNow() |
| 40 | .$onUpdate(() => |
| 41 | .notNull(), |
| 42 | }, |
| 43 | (table) => |
| 44 | ) |
| 45 | |
| 46 | export const proposalDeliverables = |
| 47 | id: text('id |
| 48 | .primaryKey() |
| 49 | .$defaultFn(() => |
| 50 | proposalId: text('proposal_id |
| 51 | .references(() => |
| 52 | .notNull(), |
| 53 | title: text('title |
| 54 | quantity: numeric('quantity |
| 55 | unitPrice: numeric('unit_price |
| 56 | amount: numeric('amount |
| 57 | sortOrder: integer('sort_order |
| 58 | }) |
| 59 | |
| 60 | export const proposalRecipients = |
| 61 | id: text('id |
| 62 | .primaryKey() |
| 63 | .$defaultFn(() => |
| 64 | proposalId: text('proposal_id |
| 65 | .references(() => |
| 66 | .notNull(), |
| 67 | clientMemberId: text('client_member_id |
| 68 | .references(() => |
| 69 | .notNull(), |
| 70 | sentAt: timestamp('sent_at |
| 71 | }) |
| 72 | |
| 73 | export const proposalSignatures = |
| 74 | id: text('id |
| 75 | .primaryKey() |
| 76 | .$defaultFn(() => |
| 77 | proposalId: text('proposal_id |
| 78 | .references(() => |
| 79 | .notNull(), |
| 80 | clientMemberId: text('client_member_id |
| 81 | .references(() => |
| 82 | .notNull(), |
| 83 | mediaId: text('media_id |
| 84 | onDelete: 'set null', |
| 85 | }), |
| 86 | signedAt: timestamp('signed_at |
| 87 | }) |