Files
pn-new-crm/src/lib/db/schema/ports.ts
Matt 67d7e6e3d5
Some checks failed
Build & Push Docker Images / build-and-push (push) Has been cancelled
Build & Push Docker Images / deploy (push) Has been cancelled
Build & Push Docker Images / lint (push) Has been cancelled
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00

51 lines
1.5 KiB
TypeScript

import { pgTable, text, boolean, timestamp, jsonb, uniqueIndex } from 'drizzle-orm/pg-core';
// Port settings type for JSONB column
export type PortSettings = {
berth_status_rules?: Array<{
trigger: string;
mode: 'auto' | 'suggest' | 'off';
target_status: string;
}>;
follow_up_defaults?: {
reminder_days: number;
send_window_hours: number[];
cooldown_days: number;
};
eoi_reminder_settings?: {
schedule: string[];
cooldown_days: number;
send_window_hours: number[];
};
[key: string]: unknown;
};
export type PortBranding = {
logo_url?: string;
primary_color?: string;
secondary_color?: string;
font_family?: string;
[key: string]: unknown;
};
export const ports = pgTable(
'ports',
{
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
name: text('name').notNull(),
slug: text('slug').notNull(),
logoUrl: text('logo_url'),
primaryColor: text('primary_color'),
defaultCurrency: text('default_currency').notNull().default('USD'),
timezone: text('timezone').notNull().default('America/Anguilla'),
settings: jsonb('settings').$type<PortSettings>().notNull().default({}),
isActive: boolean('is_active').notNull().default(true),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(table) => [uniqueIndex('ports_slug_idx').on(table.slug)],
);
export type Port = typeof ports.$inferSelect;
export type NewPort = typeof ports.$inferInsert;