feat: add client_addresses table for multi-address storage
Adds client_addresses table with cascade deletes, port scoping, primary address flag, and indexes. Updates clientsRelations and portsRelations, adds clientAddressesRelations. Generates migration 0000_narrow_longshot.sql. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
clientNotes,
|
||||
clientTags,
|
||||
clientMergeLog,
|
||||
clientAddresses,
|
||||
} from './clients';
|
||||
|
||||
// Interests
|
||||
@@ -100,6 +101,7 @@ export const portsRelations = relations(ports, ({ many }) => ({
|
||||
berthMaintenanceLogs: many(berthMaintenanceLog),
|
||||
clientMergeLogs: many(clientMergeLog),
|
||||
clientRelationships: many(clientRelationships),
|
||||
clientAddresses: many(clientAddresses),
|
||||
}));
|
||||
|
||||
// ─── Users ────────────────────────────────────────────────────────────────────
|
||||
@@ -156,6 +158,7 @@ export const clientsRelations = relations(clients, ({ one, many }) => ({
|
||||
waitingListEntries: many(berthWaitingList),
|
||||
scratchpadNotes: many(scratchpadNotes),
|
||||
formSubmissions: many(formSubmissions),
|
||||
addresses: many(clientAddresses),
|
||||
}));
|
||||
|
||||
export const clientContactsRelations = relations(clientContacts, ({ one }) => ({
|
||||
@@ -165,6 +168,17 @@ export const clientContactsRelations = relations(clientContacts, ({ one }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const clientAddressesRelations = relations(clientAddresses, ({ one }) => ({
|
||||
client: one(clients, {
|
||||
fields: [clientAddresses.clientId],
|
||||
references: [clients.id],
|
||||
}),
|
||||
port: one(ports, {
|
||||
fields: [clientAddresses.portId],
|
||||
references: [ports.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const clientRelationshipsRelations = relations(clientRelationships, ({ one }) => ({
|
||||
port: one(ports, {
|
||||
fields: [clientRelationships.portId],
|
||||
|
||||
Reference in New Issue
Block a user