feat(CC-063): add contacts, risks, projects to Drizzle schema

This commit is contained in:
admin-valentin 2026-08-01 21:20:50 +00:00
parent da8ac3359a
commit 2928271b44

View file

@ -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'),
});