diff --git a/src/db/schema.ts b/src/db/schema.ts index 8e1334f..6c8c3da 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -721,3 +721,69 @@ export const projects = pgTable('projects', { updatedAt: timestamp('updated_at').defaultNow().notNull(), deletedAt: timestamp('deleted_at'), }); + + +// ============================================================ +// Contracts +// ============================================================ +export const contracts = pgTable('contracts', { + id: uuid('id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + workspaceId: uuid('workspace_id'), + organizationId: uuid('organization_id'), + title: text('title').notNull(), + contractType: text('contract_type').notNull().default('other'), + status: text('status').notNull().default('draft'), + parties: text('parties').array().notNull().default([]), + startDate: text('start_date'), + endDate: text('end_date'), + valueMinorUnits: integer('value_minor_units'), + currency: text('currency').default('RON'), + notes: text('notes'), + tags: text('tags').array().notNull().default([]), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at').defaultNow().notNull(), + deletedAt: timestamp('deleted_at'), +}); + +// ============================================================ +// Obligations (Deadlines & Obligations) +// ============================================================ +export const obligations = pgTable('obligations', { + id: uuid('id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + workspaceId: uuid('workspace_id'), + title: text('title').notNull(), + description: text('description'), + category: text('category').notNull().default('contractual'), + status: text('status').notNull().default('pending'), + dueDate: text('due_date'), + owner: text('owner'), + contractId: uuid('contract_id'), + evidenceUrl: text('evidence_url'), + riskLevel: text('risk_level').notNull().default('medium'), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at').defaultNow().notNull(), +}); + +// ============================================================ +// Pipeline Deals (Sales Pipeline) +// ============================================================ +export const pipelineDeals = pgTable('pipeline_deals', { + id: uuid('id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + workspaceId: uuid('workspace_id'), + organizationId: uuid('organization_id'), + contactId: uuid('contact_id'), + title: text('title').notNull(), + stage: text('stage').notNull().default('identified'), + valueMinorUnits: integer('value_minor_units'), + currency: text('currency').default('RON'), + probability: integer('probability').default(50), + expectedCloseDate: text('expected_close_date'), + notes: text('notes'), + tags: text('tags').array().notNull().default([]), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at').defaultNow().notNull(), + deletedAt: timestamp('deleted_at'), +});