feat(schema): add yachtId to interests and berth_waiting_list
This commit is contained in:
@@ -17,7 +17,9 @@ import { clients } from './clients';
|
||||
export const berths = pgTable(
|
||||
'berths',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
portId: text('port_id')
|
||||
.notNull()
|
||||
.references(() => ports.id),
|
||||
@@ -70,7 +72,9 @@ export const berths = pgTable(
|
||||
export const berthMapData = pgTable(
|
||||
'berth_map_data',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
berthId: text('berth_id')
|
||||
.notNull()
|
||||
.unique()
|
||||
@@ -89,7 +93,9 @@ export const berthMapData = pgTable(
|
||||
export const berthRecommendations = pgTable(
|
||||
'berth_recommendations',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
interestId: text('interest_id').notNull(), // references interests.id
|
||||
berthId: text('berth_id')
|
||||
.notNull()
|
||||
@@ -109,13 +115,16 @@ export const berthRecommendations = pgTable(
|
||||
export const berthWaitingList = pgTable(
|
||||
'berth_waiting_list',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
berthId: text('berth_id')
|
||||
.notNull()
|
||||
.references(() => berths.id, { onDelete: 'cascade' }),
|
||||
clientId: text('client_id')
|
||||
.notNull()
|
||||
.references(() => clients.id, { onDelete: 'cascade' }),
|
||||
yachtId: text('yacht_id'), // FK added via relation; nullable (waiting for this yacht)
|
||||
position: integer('position').notNull(),
|
||||
priority: text('priority').notNull().default('normal'), // normal, high
|
||||
notifyPref: text('notify_pref').default('email'), // email, in_app, both
|
||||
@@ -131,7 +140,9 @@ export const berthWaitingList = pgTable(
|
||||
export const berthMaintenanceLog = pgTable(
|
||||
'berth_maintenance_log',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
berthId: text('berth_id')
|
||||
.notNull()
|
||||
.references(() => berths.id, { onDelete: 'cascade' }),
|
||||
@@ -149,10 +160,7 @@ export const berthMaintenanceLog = pgTable(
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
index('idx_bml_berth').on(table.berthId),
|
||||
index('idx_bml_port').on(table.portId),
|
||||
],
|
||||
(table) => [index('idx_bml_berth').on(table.berthId), index('idx_bml_port').on(table.portId)],
|
||||
);
|
||||
|
||||
export const berthTags = pgTable(
|
||||
|
||||
Reference in New Issue
Block a user