From 2928271b44b01aaff818aef9bfc5571ff6408754 Mon Sep 17 00:00:00 2001 From: admin-valentin Date: Sat, 1 Aug 2026 21:20:50 +0000 Subject: [PATCH] feat(CC-063): add contacts, risks, projects to Drizzle schema --- src/db/schema.ts | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/db/schema.ts b/src/db/schema.ts index b606d4f..8e1334f 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -655,3 +655,69 @@ export const financialSignals = pgTable( index('financial_signals_tenant_idx').on(t.tenantId, t.publishedAt), ], ); + + +// ============================================================ +// Contacts (CRM) +// ============================================================ +export const contacts = pgTable('contacts', { + id: uuid('id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + workspaceId: uuid('workspace_id'), + organizationId: uuid('organization_id'), + fullName: text('full_name').notNull(), + email: text('email'), + phone: text('phone'), + role: text('role'), + linkedinUrl: text('linkedin_url'), + notes: text('notes'), + tags: text('tags').array().notNull().default([]), + source: text('source'), + consentStatus: text('consent_status').notNull().default('unknown'), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at').defaultNow().notNull(), + deletedAt: timestamp('deleted_at'), +}); + +// ============================================================ +// Risks (Risk Register) +// ============================================================ +export const risks = pgTable('risks', { + id: uuid('id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + workspaceId: uuid('workspace_id'), + title: text('title').notNull(), + description: text('description'), + category: text('category'), + probability: text('probability').notNull().default('medium'), + impact: text('impact').notNull().default('medium'), + status: text('status').notNull().default('open'), + mitigation: text('mitigation'), + owner: text('owner'), + decisionId: uuid('decision_id'), + reviewDueAt: timestamp('review_due_at'), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at').defaultNow().notNull(), +}); + +// ============================================================ +// Projects +// ============================================================ +export const projects = pgTable('projects', { + id: uuid('id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + workspaceId: uuid('workspace_id'), + organizationId: uuid('organization_id'), + name: text('name').notNull(), + description: text('description'), + status: text('status').notNull().default('planning'), + priority: text('priority').notNull().default('medium'), + startDate: text('start_date'), + dueDate: text('due_date'), + budgetMinorUnits: integer('budget_minor_units'), + currency: text('currency').default('RON'), + tags: text('tags').array().notNull().default([]), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at').defaultNow().notNull(), + deletedAt: timestamp('deleted_at'), +});