@voyant-travel/distribution 0.115.0 → 0.116.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,739 @@
1
+ DO $$ BEGIN
2
+ CREATE TYPE "public"."booking_dist_payment_owner" AS ENUM('operator', 'channel', 'split');
3
+ EXCEPTION WHEN duplicate_object THEN null;
4
+ END $$;--> statement-breakpoint
5
+ DO $$ BEGIN
6
+ CREATE TYPE "public"."external_ref_status" AS ENUM('active', 'inactive', 'archived');
7
+ EXCEPTION WHEN duplicate_object THEN null;
8
+ END $$;--> statement-breakpoint
9
+ DO $$ BEGIN
10
+ CREATE TYPE "public"."channel_allotment_release_mode" AS ENUM('automatic', 'manual');
11
+ EXCEPTION WHEN duplicate_object THEN null;
12
+ END $$;--> statement-breakpoint
13
+ DO $$ BEGIN
14
+ CREATE TYPE "public"."channel_allotment_unsold_action" AS ENUM('release_to_general_pool', 'expire', 'retain');
15
+ EXCEPTION WHEN duplicate_object THEN null;
16
+ END $$;--> statement-breakpoint
17
+ DO $$ BEGIN
18
+ CREATE TYPE "public"."channel_commission_scope" AS ENUM('booking', 'product', 'rate', 'category');
19
+ EXCEPTION WHEN duplicate_object THEN null;
20
+ END $$;--> statement-breakpoint
21
+ DO $$ BEGIN
22
+ CREATE TYPE "public"."channel_commission_type" AS ENUM('fixed', 'percentage');
23
+ EXCEPTION WHEN duplicate_object THEN null;
24
+ END $$;--> statement-breakpoint
25
+ DO $$ BEGIN
26
+ CREATE TYPE "public"."channel_contract_status" AS ENUM('draft', 'active', 'expired', 'terminated');
27
+ EXCEPTION WHEN duplicate_object THEN null;
28
+ END $$;--> statement-breakpoint
29
+ DO $$ BEGIN
30
+ CREATE TYPE "public"."channel_kind" AS ENUM('direct', 'affiliate', 'ota', 'reseller', 'marketplace', 'api_partner', 'connect');
31
+ EXCEPTION WHEN duplicate_object THEN null;
32
+ END $$;--> statement-breakpoint
33
+ DO $$ BEGIN
34
+ CREATE TYPE "public"."channel_reconciliation_issue_type" AS ENUM('missing_booking', 'status_mismatch', 'amount_mismatch', 'cancel_mismatch', 'missing_payout', 'other');
35
+ EXCEPTION WHEN duplicate_object THEN null;
36
+ END $$;--> statement-breakpoint
37
+ DO $$ BEGIN
38
+ CREATE TYPE "public"."channel_reconciliation_policy_frequency" AS ENUM('manual', 'daily', 'weekly', 'monthly');
39
+ EXCEPTION WHEN duplicate_object THEN null;
40
+ END $$;--> statement-breakpoint
41
+ DO $$ BEGIN
42
+ CREATE TYPE "public"."channel_reconciliation_resolution_status" AS ENUM('open', 'ignored', 'resolved');
43
+ EXCEPTION WHEN duplicate_object THEN null;
44
+ END $$;--> statement-breakpoint
45
+ DO $$ BEGIN
46
+ CREATE TYPE "public"."channel_reconciliation_run_status" AS ENUM('draft', 'running', 'completed', 'archived');
47
+ EXCEPTION WHEN duplicate_object THEN null;
48
+ END $$;--> statement-breakpoint
49
+ DO $$ BEGIN
50
+ CREATE TYPE "public"."channel_reconciliation_severity" AS ENUM('info', 'warning', 'error');
51
+ EXCEPTION WHEN duplicate_object THEN null;
52
+ END $$;--> statement-breakpoint
53
+ DO $$ BEGIN
54
+ CREATE TYPE "public"."channel_release_execution_action" AS ENUM('released', 'expired', 'retained', 'manual_override');
55
+ EXCEPTION WHEN duplicate_object THEN null;
56
+ END $$;--> statement-breakpoint
57
+ DO $$ BEGIN
58
+ CREATE TYPE "public"."channel_release_execution_status" AS ENUM('pending', 'completed', 'skipped', 'failed');
59
+ EXCEPTION WHEN duplicate_object THEN null;
60
+ END $$;--> statement-breakpoint
61
+ DO $$ BEGIN
62
+ CREATE TYPE "public"."channel_release_schedule_kind" AS ENUM('manual', 'hourly', 'daily');
63
+ EXCEPTION WHEN duplicate_object THEN null;
64
+ END $$;--> statement-breakpoint
65
+ DO $$ BEGIN
66
+ CREATE TYPE "public"."channel_remittance_exception_status" AS ENUM('open', 'investigating', 'resolved', 'ignored');
67
+ EXCEPTION WHEN duplicate_object THEN null;
68
+ END $$;--> statement-breakpoint
69
+ DO $$ BEGIN
70
+ CREATE TYPE "public"."channel_settlement_approval_status" AS ENUM('pending', 'approved', 'rejected');
71
+ EXCEPTION WHEN duplicate_object THEN null;
72
+ END $$;--> statement-breakpoint
73
+ DO $$ BEGIN
74
+ CREATE TYPE "public"."channel_settlement_item_status" AS ENUM('pending', 'approved', 'disputed', 'paid', 'void');
75
+ EXCEPTION WHEN duplicate_object THEN null;
76
+ END $$;--> statement-breakpoint
77
+ DO $$ BEGIN
78
+ CREATE TYPE "public"."channel_settlement_policy_frequency" AS ENUM('manual', 'daily', 'weekly', 'monthly');
79
+ EXCEPTION WHEN duplicate_object THEN null;
80
+ END $$;--> statement-breakpoint
81
+ DO $$ BEGIN
82
+ CREATE TYPE "public"."channel_settlement_run_status" AS ENUM('draft', 'open', 'posted', 'paid', 'void');
83
+ EXCEPTION WHEN duplicate_object THEN null;
84
+ END $$;--> statement-breakpoint
85
+ DO $$ BEGIN
86
+ CREATE TYPE "public"."channel_status" AS ENUM('active', 'inactive', 'pending', 'archived');
87
+ EXCEPTION WHEN duplicate_object THEN null;
88
+ END $$;--> statement-breakpoint
89
+ DO $$ BEGIN
90
+ CREATE TYPE "public"."channel_webhook_status" AS ENUM('pending', 'processed', 'failed', 'ignored');
91
+ EXCEPTION WHEN duplicate_object THEN null;
92
+ END $$;--> statement-breakpoint
93
+ DO $$ BEGIN
94
+ CREATE TYPE "public"."distribution_cancellation_owner" AS ENUM('operator', 'channel', 'mixed');
95
+ EXCEPTION WHEN duplicate_object THEN null;
96
+ END $$;--> statement-breakpoint
97
+ DO $$ BEGIN
98
+ CREATE TYPE "public"."distribution_payment_owner" AS ENUM('operator', 'channel', 'split');
99
+ EXCEPTION WHEN duplicate_object THEN null;
100
+ END $$;--> statement-breakpoint
101
+ DO $$ BEGIN
102
+ CREATE TYPE "public"."rate_unit" AS ENUM('per_person', 'per_group', 'per_night', 'per_vehicle', 'flat');
103
+ EXCEPTION WHEN duplicate_object THEN null;
104
+ END $$;--> statement-breakpoint
105
+ DO $$ BEGIN
106
+ CREATE TYPE "public"."service_type" AS ENUM('accommodation', 'transfer', 'experience', 'guide', 'meal', 'other');
107
+ EXCEPTION WHEN duplicate_object THEN null;
108
+ END $$;--> statement-breakpoint
109
+ DO $$ BEGIN
110
+ CREATE TYPE "public"."supplier_contract_status" AS ENUM('active', 'expired', 'pending', 'terminated');
111
+ EXCEPTION WHEN duplicate_object THEN null;
112
+ END $$;--> statement-breakpoint
113
+ DO $$ BEGIN
114
+ CREATE TYPE "public"."supplier_status" AS ENUM('active', 'inactive', 'pending');
115
+ EXCEPTION WHEN duplicate_object THEN null;
116
+ END $$;--> statement-breakpoint
117
+ DO $$ BEGIN
118
+ CREATE TYPE "public"."supplier_type" AS ENUM('hotel', 'transfer', 'guide', 'experience', 'airline', 'restaurant', 'other');
119
+ EXCEPTION WHEN duplicate_object THEN null;
120
+ END $$;--> statement-breakpoint
121
+ CREATE TABLE "booking_distribution_details" (
122
+ "booking_id" text PRIMARY KEY NOT NULL,
123
+ "market_id" text,
124
+ "source_channel_id" text,
125
+ "fx_rate_set_id" text,
126
+ "payment_owner" "booking_dist_payment_owner" DEFAULT 'operator' NOT NULL,
127
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
128
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
129
+ );
130
+ --> statement-breakpoint
131
+ CREATE TABLE "external_refs" (
132
+ "id" text PRIMARY KEY NOT NULL,
133
+ "entity_type" text NOT NULL,
134
+ "entity_id" text NOT NULL,
135
+ "source_system" text NOT NULL,
136
+ "object_type" text NOT NULL,
137
+ "namespace" text DEFAULT 'default' NOT NULL,
138
+ "external_id" text NOT NULL,
139
+ "external_parent_id" text,
140
+ "is_primary" boolean DEFAULT false NOT NULL,
141
+ "status" "external_ref_status" DEFAULT 'active' NOT NULL,
142
+ "last_synced_at" timestamp with time zone,
143
+ "metadata" jsonb,
144
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
145
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
146
+ );
147
+ --> statement-breakpoint
148
+ CREATE TABLE "channel_reconciliation_policies" (
149
+ "id" text PRIMARY KEY NOT NULL,
150
+ "channel_id" text NOT NULL,
151
+ "contract_id" text,
152
+ "frequency" "channel_reconciliation_policy_frequency" DEFAULT 'manual' NOT NULL,
153
+ "auto_run" boolean DEFAULT false NOT NULL,
154
+ "compare_gross_amounts" boolean DEFAULT true NOT NULL,
155
+ "compare_statuses" boolean DEFAULT true NOT NULL,
156
+ "compare_cancellations" boolean DEFAULT true NOT NULL,
157
+ "amount_tolerance_cents" integer,
158
+ "active" boolean DEFAULT true NOT NULL,
159
+ "notes" text,
160
+ "metadata" jsonb,
161
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
162
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
163
+ );
164
+ --> statement-breakpoint
165
+ CREATE TABLE "channel_release_schedules" (
166
+ "id" text PRIMARY KEY NOT NULL,
167
+ "release_rule_id" text NOT NULL,
168
+ "schedule_kind" "channel_release_schedule_kind" DEFAULT 'manual' NOT NULL,
169
+ "next_run_at" timestamp with time zone,
170
+ "last_run_at" timestamp with time zone,
171
+ "active" boolean DEFAULT true NOT NULL,
172
+ "notes" text,
173
+ "metadata" jsonb,
174
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
175
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
176
+ );
177
+ --> statement-breakpoint
178
+ CREATE TABLE "channel_settlement_policies" (
179
+ "id" text PRIMARY KEY NOT NULL,
180
+ "channel_id" text NOT NULL,
181
+ "contract_id" text,
182
+ "frequency" "channel_settlement_policy_frequency" DEFAULT 'manual' NOT NULL,
183
+ "auto_generate" boolean DEFAULT false NOT NULL,
184
+ "approval_required" boolean DEFAULT false NOT NULL,
185
+ "remittance_days_after_period_end" integer,
186
+ "minimum_payout_amount_cents" integer,
187
+ "currency_code" text,
188
+ "active" boolean DEFAULT true NOT NULL,
189
+ "notes" text,
190
+ "metadata" jsonb,
191
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
192
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
193
+ );
194
+ --> statement-breakpoint
195
+ CREATE TABLE "channel_booking_links" (
196
+ "id" text PRIMARY KEY NOT NULL,
197
+ "channel_id" text NOT NULL,
198
+ "booking_id" text NOT NULL,
199
+ "booking_item_id" text,
200
+ "external_booking_id" text,
201
+ "external_reference" text,
202
+ "external_status" text,
203
+ "booked_at_external" timestamp with time zone,
204
+ "last_synced_at" timestamp with time zone,
205
+ "source_kind" text,
206
+ "source_connection_id" text,
207
+ "push_status" text DEFAULT 'pending' NOT NULL,
208
+ "push_attempts" integer DEFAULT 0 NOT NULL,
209
+ "last_push_at" timestamp with time zone,
210
+ "last_error" text,
211
+ "pushed_payload_hash" text,
212
+ "idempotency_key" text,
213
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
214
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
215
+ );
216
+ --> statement-breakpoint
217
+ CREATE TABLE "channel_commission_rules" (
218
+ "id" text PRIMARY KEY NOT NULL,
219
+ "contract_id" text NOT NULL,
220
+ "scope" "channel_commission_scope" NOT NULL,
221
+ "product_id" text,
222
+ "external_rate_id" text,
223
+ "external_category_id" text,
224
+ "commission_type" "channel_commission_type" NOT NULL,
225
+ "amount_cents" integer,
226
+ "percent_basis_points" integer,
227
+ "valid_from" date,
228
+ "valid_to" date,
229
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
230
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
231
+ );
232
+ --> statement-breakpoint
233
+ CREATE TABLE "channel_contact_projections" (
234
+ "channel_id" text PRIMARY KEY NOT NULL,
235
+ "website_contact_point_id" text,
236
+ "primary_named_contact_id" text,
237
+ "website" text,
238
+ "contact_name" text,
239
+ "contact_email" text,
240
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
241
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
242
+ );
243
+ --> statement-breakpoint
244
+ CREATE TABLE "channel_contracts" (
245
+ "id" text PRIMARY KEY NOT NULL,
246
+ "channel_id" text NOT NULL,
247
+ "supplier_id" text,
248
+ "status" "channel_contract_status" DEFAULT 'draft' NOT NULL,
249
+ "starts_at" date NOT NULL,
250
+ "ends_at" date,
251
+ "payment_owner" "distribution_payment_owner" DEFAULT 'operator' NOT NULL,
252
+ "cancellation_owner" "distribution_cancellation_owner" DEFAULT 'operator' NOT NULL,
253
+ "settlement_terms" text,
254
+ "notes" text,
255
+ "rate_limit_rps" integer,
256
+ "rate_limit_burst" integer,
257
+ "rate_limit_priority_gates" jsonb,
258
+ "policy" jsonb,
259
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
260
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
261
+ );
262
+ --> statement-breakpoint
263
+ CREATE TABLE "channel_product_mappings" (
264
+ "id" text PRIMARY KEY NOT NULL,
265
+ "channel_id" text NOT NULL,
266
+ "product_id" text NOT NULL,
267
+ "external_product_id" text,
268
+ "external_rate_id" text,
269
+ "external_category_id" text,
270
+ "active" boolean DEFAULT true NOT NULL,
271
+ "source_kind" text,
272
+ "source_connection_id" text,
273
+ "push_bookings" boolean DEFAULT true NOT NULL,
274
+ "push_availability" boolean DEFAULT true NOT NULL,
275
+ "push_content" boolean DEFAULT true NOT NULL,
276
+ "policy" jsonb,
277
+ "last_pushed_content_hash" text,
278
+ "last_pushed_content_at" timestamp with time zone,
279
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
280
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
281
+ );
282
+ --> statement-breakpoint
283
+ CREATE TABLE "channel_webhook_events" (
284
+ "id" text PRIMARY KEY NOT NULL,
285
+ "channel_id" text NOT NULL,
286
+ "event_type" text NOT NULL,
287
+ "external_event_id" text,
288
+ "payload" jsonb NOT NULL,
289
+ "received_at" timestamp with time zone DEFAULT now() NOT NULL,
290
+ "processed_at" timestamp with time zone,
291
+ "status" "channel_webhook_status" DEFAULT 'pending' NOT NULL,
292
+ "error_message" text,
293
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
294
+ );
295
+ --> statement-breakpoint
296
+ CREATE TABLE "channels" (
297
+ "id" text PRIMARY KEY NOT NULL,
298
+ "name" text NOT NULL,
299
+ "description" text,
300
+ "kind" "channel_kind" NOT NULL,
301
+ "status" "channel_status" DEFAULT 'active' NOT NULL,
302
+ "metadata" jsonb,
303
+ "rate_limit_rps" integer,
304
+ "rate_limit_burst" integer,
305
+ "rate_limit_priority_gates" jsonb,
306
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
307
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
308
+ );
309
+ --> statement-breakpoint
310
+ CREATE TABLE "channel_reconciliation_items" (
311
+ "id" text PRIMARY KEY NOT NULL,
312
+ "reconciliation_run_id" text NOT NULL,
313
+ "booking_link_id" text,
314
+ "booking_id" text,
315
+ "external_booking_id" text,
316
+ "issue_type" "channel_reconciliation_issue_type" DEFAULT 'other' NOT NULL,
317
+ "severity" "channel_reconciliation_severity" DEFAULT 'warning' NOT NULL,
318
+ "resolution_status" "channel_reconciliation_resolution_status" DEFAULT 'open' NOT NULL,
319
+ "notes" text,
320
+ "resolved_at" timestamp with time zone,
321
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
322
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
323
+ );
324
+ --> statement-breakpoint
325
+ CREATE TABLE "channel_reconciliation_runs" (
326
+ "id" text PRIMARY KEY NOT NULL,
327
+ "channel_id" text NOT NULL,
328
+ "contract_id" text,
329
+ "status" "channel_reconciliation_run_status" DEFAULT 'draft' NOT NULL,
330
+ "period_start" date,
331
+ "period_end" date,
332
+ "external_report_reference" text,
333
+ "started_at" timestamp with time zone,
334
+ "completed_at" timestamp with time zone,
335
+ "notes" text,
336
+ "metadata" jsonb,
337
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
338
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
339
+ );
340
+ --> statement-breakpoint
341
+ CREATE TABLE "channel_remittance_exceptions" (
342
+ "id" text PRIMARY KEY NOT NULL,
343
+ "channel_id" text NOT NULL,
344
+ "settlement_item_id" text,
345
+ "reconciliation_item_id" text,
346
+ "exception_type" text NOT NULL,
347
+ "severity" "channel_reconciliation_severity" DEFAULT 'warning' NOT NULL,
348
+ "status" "channel_remittance_exception_status" DEFAULT 'open' NOT NULL,
349
+ "opened_at" timestamp with time zone DEFAULT now() NOT NULL,
350
+ "resolved_at" timestamp with time zone,
351
+ "notes" text,
352
+ "metadata" jsonb,
353
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
354
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
355
+ );
356
+ --> statement-breakpoint
357
+ CREATE TABLE "channel_settlement_approvals" (
358
+ "id" text PRIMARY KEY NOT NULL,
359
+ "settlement_run_id" text NOT NULL,
360
+ "approver_user_id" text,
361
+ "status" "channel_settlement_approval_status" DEFAULT 'pending' NOT NULL,
362
+ "decided_at" timestamp with time zone,
363
+ "notes" text,
364
+ "metadata" jsonb,
365
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
366
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
367
+ );
368
+ --> statement-breakpoint
369
+ CREATE TABLE "channel_settlement_items" (
370
+ "id" text PRIMARY KEY NOT NULL,
371
+ "settlement_run_id" text NOT NULL,
372
+ "booking_link_id" text,
373
+ "booking_id" text,
374
+ "commission_rule_id" text,
375
+ "status" "channel_settlement_item_status" DEFAULT 'pending' NOT NULL,
376
+ "gross_amount_cents" integer DEFAULT 0 NOT NULL,
377
+ "commission_amount_cents" integer DEFAULT 0 NOT NULL,
378
+ "net_remittance_amount_cents" integer DEFAULT 0 NOT NULL,
379
+ "currency_code" text,
380
+ "remittance_due_at" timestamp with time zone,
381
+ "paid_at" timestamp with time zone,
382
+ "notes" text,
383
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
384
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
385
+ );
386
+ --> statement-breakpoint
387
+ CREATE TABLE "channel_settlement_runs" (
388
+ "id" text PRIMARY KEY NOT NULL,
389
+ "channel_id" text NOT NULL,
390
+ "contract_id" text,
391
+ "status" "channel_settlement_run_status" DEFAULT 'draft' NOT NULL,
392
+ "currency_code" text,
393
+ "period_start" date,
394
+ "period_end" date,
395
+ "statement_reference" text,
396
+ "generated_at" timestamp with time zone,
397
+ "posted_at" timestamp with time zone,
398
+ "paid_at" timestamp with time zone,
399
+ "notes" text,
400
+ "metadata" jsonb,
401
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
402
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
403
+ );
404
+ --> statement-breakpoint
405
+ CREATE TABLE "channel_inventory_allotment_targets" (
406
+ "id" text PRIMARY KEY NOT NULL,
407
+ "allotment_id" text NOT NULL,
408
+ "slot_id" text,
409
+ "start_time_id" text,
410
+ "date_local" date,
411
+ "guaranteed_capacity" integer,
412
+ "max_capacity" integer,
413
+ "sold_capacity" integer,
414
+ "remaining_capacity" integer,
415
+ "active" boolean DEFAULT true NOT NULL,
416
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
417
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
418
+ );
419
+ --> statement-breakpoint
420
+ CREATE TABLE "channel_inventory_allotments" (
421
+ "id" text PRIMARY KEY NOT NULL,
422
+ "channel_id" text NOT NULL,
423
+ "contract_id" text,
424
+ "product_id" text NOT NULL,
425
+ "option_id" text,
426
+ "start_time_id" text,
427
+ "valid_from" date,
428
+ "valid_to" date,
429
+ "guaranteed_capacity" integer,
430
+ "max_capacity" integer,
431
+ "active" boolean DEFAULT true NOT NULL,
432
+ "notes" text,
433
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
434
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
435
+ );
436
+ --> statement-breakpoint
437
+ CREATE TABLE "channel_inventory_release_executions" (
438
+ "id" text PRIMARY KEY NOT NULL,
439
+ "allotment_id" text NOT NULL,
440
+ "release_rule_id" text,
441
+ "target_id" text,
442
+ "slot_id" text,
443
+ "action_taken" "channel_release_execution_action" DEFAULT 'released' NOT NULL,
444
+ "status" "channel_release_execution_status" DEFAULT 'pending' NOT NULL,
445
+ "released_capacity" integer,
446
+ "executed_at" timestamp with time zone,
447
+ "notes" text,
448
+ "metadata" jsonb,
449
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
450
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
451
+ );
452
+ --> statement-breakpoint
453
+ CREATE TABLE "channel_inventory_release_rules" (
454
+ "id" text PRIMARY KEY NOT NULL,
455
+ "allotment_id" text NOT NULL,
456
+ "release_mode" "channel_allotment_release_mode" DEFAULT 'automatic' NOT NULL,
457
+ "release_days_before_start" integer,
458
+ "release_hours_before_start" integer,
459
+ "unsold_action" "channel_allotment_unsold_action" DEFAULT 'release_to_general_pool' NOT NULL,
460
+ "notes" text,
461
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
462
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
463
+ );
464
+ --> statement-breakpoint
465
+ CREATE TABLE "channel_availability_push_intents" (
466
+ "id" text PRIMARY KEY NOT NULL,
467
+ "channel_id" text NOT NULL,
468
+ "source_connection_id" text NOT NULL,
469
+ "slot_id" text NOT NULL,
470
+ "product_id" text NOT NULL,
471
+ "option_id" text,
472
+ "starts_at" timestamp with time zone NOT NULL,
473
+ "requested_at" timestamp with time zone DEFAULT now() NOT NULL,
474
+ "attempts" integer DEFAULT 0 NOT NULL,
475
+ "last_error" text,
476
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
477
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
478
+ );
479
+ --> statement-breakpoint
480
+ CREATE TABLE "channel_content_push_intents" (
481
+ "id" text PRIMARY KEY NOT NULL,
482
+ "channel_id" text NOT NULL,
483
+ "source_connection_id" text NOT NULL,
484
+ "product_id" text NOT NULL,
485
+ "requested_at" timestamp with time zone DEFAULT now() NOT NULL,
486
+ "attempts" integer DEFAULT 0 NOT NULL,
487
+ "last_error" text,
488
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
489
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
490
+ );
491
+ --> statement-breakpoint
492
+ CREATE TABLE "supplier_availability" (
493
+ "id" text PRIMARY KEY NOT NULL,
494
+ "supplier_id" text NOT NULL,
495
+ "date" date NOT NULL,
496
+ "available" boolean DEFAULT true NOT NULL,
497
+ "notes" text,
498
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
499
+ );
500
+ --> statement-breakpoint
501
+ CREATE TABLE "supplier_contracts" (
502
+ "id" text PRIMARY KEY NOT NULL,
503
+ "supplier_id" text NOT NULL,
504
+ "agreement_number" text,
505
+ "start_date" date NOT NULL,
506
+ "end_date" date,
507
+ "renewal_date" date,
508
+ "terms" text,
509
+ "status" "supplier_contract_status" DEFAULT 'active' NOT NULL,
510
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
511
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
512
+ );
513
+ --> statement-breakpoint
514
+ CREATE TABLE "supplier_directory_projections" (
515
+ "supplier_id" text NOT NULL,
516
+ "email" text,
517
+ "phone" text,
518
+ "website" text,
519
+ "address" text,
520
+ "city" text,
521
+ "country" text,
522
+ "contact_name" text,
523
+ "contact_email" text,
524
+ "contact_phone" text,
525
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
526
+ );
527
+ --> statement-breakpoint
528
+ CREATE TABLE "supplier_notes" (
529
+ "id" text PRIMARY KEY NOT NULL,
530
+ "supplier_id" text NOT NULL,
531
+ "author_id" text NOT NULL,
532
+ "content" text NOT NULL,
533
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
534
+ );
535
+ --> statement-breakpoint
536
+ CREATE TABLE "supplier_rates" (
537
+ "id" text PRIMARY KEY NOT NULL,
538
+ "service_id" text NOT NULL,
539
+ "name" text NOT NULL,
540
+ "currency" text NOT NULL,
541
+ "amount_cents" integer NOT NULL,
542
+ "unit" "rate_unit" NOT NULL,
543
+ "valid_from" date,
544
+ "valid_to" date,
545
+ "min_pax" integer,
546
+ "max_pax" integer,
547
+ "notes" text,
548
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
549
+ );
550
+ --> statement-breakpoint
551
+ CREATE TABLE "supplier_services" (
552
+ "id" text PRIMARY KEY NOT NULL,
553
+ "supplier_id" text NOT NULL,
554
+ "service_type" "service_type" NOT NULL,
555
+ "facility_id" text,
556
+ "name" text NOT NULL,
557
+ "description" text,
558
+ "duration" text,
559
+ "capacity" integer,
560
+ "active" boolean DEFAULT true NOT NULL,
561
+ "tags" jsonb DEFAULT '[]'::jsonb,
562
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
563
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
564
+ );
565
+ --> statement-breakpoint
566
+ CREATE TABLE "suppliers" (
567
+ "id" text PRIMARY KEY NOT NULL,
568
+ "name" text NOT NULL,
569
+ "type" "supplier_type" NOT NULL,
570
+ "status" "supplier_status" DEFAULT 'active' NOT NULL,
571
+ "description" text,
572
+ "default_currency" text,
573
+ "payment_terms_days" integer,
574
+ "reservation_timeout_minutes" integer,
575
+ "primary_facility_id" text,
576
+ "customer_payment_policy" jsonb,
577
+ "tags" jsonb DEFAULT '[]'::jsonb,
578
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
579
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
580
+ );
581
+ --> statement-breakpoint
582
+ ALTER TABLE "channel_reconciliation_policies" ADD CONSTRAINT "channel_reconciliation_policies_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
583
+ ALTER TABLE "channel_reconciliation_policies" ADD CONSTRAINT "channel_reconciliation_policies_contract_id_channel_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."channel_contracts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
584
+ ALTER TABLE "channel_release_schedules" ADD CONSTRAINT "channel_release_schedules_release_rule_id_channel_inventory_release_rules_id_fk" FOREIGN KEY ("release_rule_id") REFERENCES "public"."channel_inventory_release_rules"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
585
+ ALTER TABLE "channel_settlement_policies" ADD CONSTRAINT "channel_settlement_policies_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
586
+ ALTER TABLE "channel_settlement_policies" ADD CONSTRAINT "channel_settlement_policies_contract_id_channel_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."channel_contracts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
587
+ ALTER TABLE "channel_booking_links" ADD CONSTRAINT "channel_booking_links_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
588
+ ALTER TABLE "channel_commission_rules" ADD CONSTRAINT "channel_commission_rules_contract_id_channel_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."channel_contracts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
589
+ ALTER TABLE "channel_contact_projections" ADD CONSTRAINT "channel_contact_projections_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
590
+ ALTER TABLE "channel_contracts" ADD CONSTRAINT "channel_contracts_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
591
+ ALTER TABLE "channel_contracts" ADD CONSTRAINT "channel_contracts_supplier_id_suppliers_id_fk" FOREIGN KEY ("supplier_id") REFERENCES "public"."suppliers"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
592
+ ALTER TABLE "channel_product_mappings" ADD CONSTRAINT "channel_product_mappings_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
593
+ ALTER TABLE "channel_webhook_events" ADD CONSTRAINT "channel_webhook_events_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
594
+ ALTER TABLE "channel_reconciliation_items" ADD CONSTRAINT "channel_reconciliation_items_reconciliation_run_id_channel_reconciliation_runs_id_fk" FOREIGN KEY ("reconciliation_run_id") REFERENCES "public"."channel_reconciliation_runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
595
+ ALTER TABLE "channel_reconciliation_items" ADD CONSTRAINT "channel_reconciliation_items_booking_link_id_channel_booking_links_id_fk" FOREIGN KEY ("booking_link_id") REFERENCES "public"."channel_booking_links"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
596
+ ALTER TABLE "channel_reconciliation_runs" ADD CONSTRAINT "channel_reconciliation_runs_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
597
+ ALTER TABLE "channel_reconciliation_runs" ADD CONSTRAINT "channel_reconciliation_runs_contract_id_channel_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."channel_contracts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
598
+ ALTER TABLE "channel_remittance_exceptions" ADD CONSTRAINT "channel_remittance_exceptions_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
599
+ ALTER TABLE "channel_remittance_exceptions" ADD CONSTRAINT "channel_remittance_exceptions_settlement_item_id_channel_settlement_items_id_fk" FOREIGN KEY ("settlement_item_id") REFERENCES "public"."channel_settlement_items"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
600
+ ALTER TABLE "channel_remittance_exceptions" ADD CONSTRAINT "channel_remittance_exceptions_reconciliation_item_id_channel_reconciliation_items_id_fk" FOREIGN KEY ("reconciliation_item_id") REFERENCES "public"."channel_reconciliation_items"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
601
+ ALTER TABLE "channel_settlement_approvals" ADD CONSTRAINT "channel_settlement_approvals_settlement_run_id_channel_settlement_runs_id_fk" FOREIGN KEY ("settlement_run_id") REFERENCES "public"."channel_settlement_runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
602
+ ALTER TABLE "channel_settlement_items" ADD CONSTRAINT "channel_settlement_items_settlement_run_id_channel_settlement_runs_id_fk" FOREIGN KEY ("settlement_run_id") REFERENCES "public"."channel_settlement_runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
603
+ ALTER TABLE "channel_settlement_items" ADD CONSTRAINT "channel_settlement_items_booking_link_id_channel_booking_links_id_fk" FOREIGN KEY ("booking_link_id") REFERENCES "public"."channel_booking_links"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
604
+ ALTER TABLE "channel_settlement_items" ADD CONSTRAINT "channel_settlement_items_commission_rule_id_channel_commission_rules_id_fk" FOREIGN KEY ("commission_rule_id") REFERENCES "public"."channel_commission_rules"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
605
+ ALTER TABLE "channel_settlement_runs" ADD CONSTRAINT "channel_settlement_runs_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
606
+ ALTER TABLE "channel_settlement_runs" ADD CONSTRAINT "channel_settlement_runs_contract_id_channel_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."channel_contracts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
607
+ ALTER TABLE "channel_inventory_allotment_targets" ADD CONSTRAINT "channel_inventory_allotment_targets_allotment_id_channel_inventory_allotments_id_fk" FOREIGN KEY ("allotment_id") REFERENCES "public"."channel_inventory_allotments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
608
+ ALTER TABLE "channel_inventory_allotments" ADD CONSTRAINT "channel_inventory_allotments_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
609
+ ALTER TABLE "channel_inventory_allotments" ADD CONSTRAINT "channel_inventory_allotments_contract_id_channel_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."channel_contracts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
610
+ ALTER TABLE "channel_inventory_release_executions" ADD CONSTRAINT "channel_inventory_release_executions_allotment_id_channel_inventory_allotments_id_fk" FOREIGN KEY ("allotment_id") REFERENCES "public"."channel_inventory_allotments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
611
+ ALTER TABLE "channel_inventory_release_executions" ADD CONSTRAINT "channel_inventory_release_executions_release_rule_id_channel_inventory_release_rules_id_fk" FOREIGN KEY ("release_rule_id") REFERENCES "public"."channel_inventory_release_rules"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
612
+ ALTER TABLE "channel_inventory_release_executions" ADD CONSTRAINT "channel_inventory_release_executions_target_id_channel_inventory_allotment_targets_id_fk" FOREIGN KEY ("target_id") REFERENCES "public"."channel_inventory_allotment_targets"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
613
+ ALTER TABLE "channel_inventory_release_rules" ADD CONSTRAINT "channel_inventory_release_rules_allotment_id_channel_inventory_allotments_id_fk" FOREIGN KEY ("allotment_id") REFERENCES "public"."channel_inventory_allotments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
614
+ ALTER TABLE "channel_availability_push_intents" ADD CONSTRAINT "channel_availability_push_intents_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
615
+ ALTER TABLE "channel_content_push_intents" ADD CONSTRAINT "channel_content_push_intents_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
616
+ ALTER TABLE "supplier_availability" ADD CONSTRAINT "supplier_availability_supplier_id_suppliers_id_fk" FOREIGN KEY ("supplier_id") REFERENCES "public"."suppliers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
617
+ ALTER TABLE "supplier_contracts" ADD CONSTRAINT "supplier_contracts_supplier_id_suppliers_id_fk" FOREIGN KEY ("supplier_id") REFERENCES "public"."suppliers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
618
+ ALTER TABLE "supplier_directory_projections" ADD CONSTRAINT "supplier_directory_projections_supplier_id_suppliers_id_fk" FOREIGN KEY ("supplier_id") REFERENCES "public"."suppliers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
619
+ ALTER TABLE "supplier_notes" ADD CONSTRAINT "supplier_notes_supplier_id_suppliers_id_fk" FOREIGN KEY ("supplier_id") REFERENCES "public"."suppliers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
620
+ ALTER TABLE "supplier_rates" ADD CONSTRAINT "supplier_rates_service_id_supplier_services_id_fk" FOREIGN KEY ("service_id") REFERENCES "public"."supplier_services"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
621
+ ALTER TABLE "supplier_services" ADD CONSTRAINT "supplier_services_supplier_id_suppliers_id_fk" FOREIGN KEY ("supplier_id") REFERENCES "public"."suppliers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
622
+ CREATE INDEX "idx_bdd_market" ON "booking_distribution_details" USING btree ("market_id");--> statement-breakpoint
623
+ CREATE INDEX "idx_bdd_source_channel" ON "booking_distribution_details" USING btree ("source_channel_id");--> statement-breakpoint
624
+ CREATE INDEX "idx_bdd_fx_rate_set" ON "booking_distribution_details" USING btree ("fx_rate_set_id");--> statement-breakpoint
625
+ CREATE INDEX "idx_external_refs_updated" ON "external_refs" USING btree ("updated_at");--> statement-breakpoint
626
+ CREATE INDEX "idx_external_refs_entity_updated" ON "external_refs" USING btree ("entity_type","entity_id","updated_at");--> statement-breakpoint
627
+ CREATE INDEX "idx_external_refs_source_updated" ON "external_refs" USING btree ("source_system","object_type","updated_at");--> statement-breakpoint
628
+ CREATE INDEX "idx_external_refs_namespace_updated" ON "external_refs" USING btree ("namespace","updated_at");--> statement-breakpoint
629
+ CREATE INDEX "idx_external_refs_external_id" ON "external_refs" USING btree ("external_id");--> statement-breakpoint
630
+ CREATE INDEX "idx_external_refs_status_updated" ON "external_refs" USING btree ("status","updated_at");--> statement-breakpoint
631
+ CREATE UNIQUE INDEX "uidx_external_refs_entity_source_external" ON "external_refs" USING btree ("entity_type","entity_id","source_system","namespace","external_id");--> statement-breakpoint
632
+ CREATE UNIQUE INDEX "uidx_external_refs_source_object_external" ON "external_refs" USING btree ("source_system","object_type","namespace","external_id");--> statement-breakpoint
633
+ CREATE INDEX "idx_channel_reconciliation_policies_updated" ON "channel_reconciliation_policies" USING btree ("updated_at");--> statement-breakpoint
634
+ CREATE INDEX "idx_channel_reconciliation_policies_channel_updated" ON "channel_reconciliation_policies" USING btree ("channel_id","updated_at");--> statement-breakpoint
635
+ CREATE INDEX "idx_channel_reconciliation_policies_contract_updated" ON "channel_reconciliation_policies" USING btree ("contract_id","updated_at");--> statement-breakpoint
636
+ CREATE INDEX "idx_channel_reconciliation_policies_frequency_updated" ON "channel_reconciliation_policies" USING btree ("frequency","updated_at");--> statement-breakpoint
637
+ CREATE INDEX "idx_channel_reconciliation_policies_active_updated" ON "channel_reconciliation_policies" USING btree ("active","updated_at");--> statement-breakpoint
638
+ CREATE INDEX "idx_channel_release_schedules_updated" ON "channel_release_schedules" USING btree ("updated_at");--> statement-breakpoint
639
+ CREATE INDEX "idx_channel_release_schedules_rule_updated" ON "channel_release_schedules" USING btree ("release_rule_id","updated_at");--> statement-breakpoint
640
+ CREATE INDEX "idx_channel_release_schedules_kind_updated" ON "channel_release_schedules" USING btree ("schedule_kind","updated_at");--> statement-breakpoint
641
+ CREATE INDEX "idx_channel_release_schedules_active_updated" ON "channel_release_schedules" USING btree ("active","updated_at");--> statement-breakpoint
642
+ CREATE INDEX "idx_channel_settlement_policies_updated" ON "channel_settlement_policies" USING btree ("updated_at");--> statement-breakpoint
643
+ CREATE INDEX "idx_channel_settlement_policies_channel_updated" ON "channel_settlement_policies" USING btree ("channel_id","updated_at");--> statement-breakpoint
644
+ CREATE INDEX "idx_channel_settlement_policies_contract_updated" ON "channel_settlement_policies" USING btree ("contract_id","updated_at");--> statement-breakpoint
645
+ CREATE INDEX "idx_channel_settlement_policies_frequency_updated" ON "channel_settlement_policies" USING btree ("frequency","updated_at");--> statement-breakpoint
646
+ CREATE INDEX "idx_channel_settlement_policies_active_updated" ON "channel_settlement_policies" USING btree ("active","updated_at");--> statement-breakpoint
647
+ CREATE INDEX "idx_channel_booking_links_channel_created" ON "channel_booking_links" USING btree ("channel_id","created_at");--> statement-breakpoint
648
+ CREATE INDEX "idx_channel_booking_links_booking_created" ON "channel_booking_links" USING btree ("booking_id","created_at");--> statement-breakpoint
649
+ CREATE INDEX "idx_channel_booking_links_external_booking_created" ON "channel_booking_links" USING btree ("external_booking_id","created_at");--> statement-breakpoint
650
+ CREATE INDEX "idx_channel_booking_links_push_status" ON "channel_booking_links" USING btree ("push_status","last_push_at");--> statement-breakpoint
651
+ CREATE INDEX "idx_channel_booking_links_booking_item" ON "channel_booking_links" USING btree ("booking_item_id") WHERE "channel_booking_links"."booking_item_id" IS NOT NULL;--> statement-breakpoint
652
+ CREATE UNIQUE INDEX "uniq_channel_booking_links_per_item" ON "channel_booking_links" USING btree ("channel_id","booking_id",COALESCE("booking_item_id", ''));--> statement-breakpoint
653
+ CREATE INDEX "idx_channel_commission_rules_contract_created" ON "channel_commission_rules" USING btree ("contract_id","created_at");--> statement-breakpoint
654
+ CREATE INDEX "idx_channel_commission_rules_product_created" ON "channel_commission_rules" USING btree ("product_id","created_at");--> statement-breakpoint
655
+ CREATE INDEX "idx_channel_commission_rules_scope_created" ON "channel_commission_rules" USING btree ("scope","created_at");--> statement-breakpoint
656
+ CREATE INDEX "idx_channel_contracts_channel_created" ON "channel_contracts" USING btree ("channel_id","created_at");--> statement-breakpoint
657
+ CREATE INDEX "idx_channel_contracts_supplier_created" ON "channel_contracts" USING btree ("supplier_id","created_at");--> statement-breakpoint
658
+ CREATE INDEX "idx_channel_contracts_status_created" ON "channel_contracts" USING btree ("status","created_at");--> statement-breakpoint
659
+ CREATE INDEX "idx_channel_product_mappings_channel_created" ON "channel_product_mappings" USING btree ("channel_id","created_at");--> statement-breakpoint
660
+ CREATE INDEX "idx_channel_product_mappings_product_created" ON "channel_product_mappings" USING btree ("product_id","created_at");--> statement-breakpoint
661
+ CREATE INDEX "idx_channel_product_mappings_active_created" ON "channel_product_mappings" USING btree ("active","created_at");--> statement-breakpoint
662
+ CREATE INDEX "idx_channel_product_mappings_source_connection" ON "channel_product_mappings" USING btree ("source_connection_id");--> statement-breakpoint
663
+ CREATE INDEX "idx_channel_webhook_events_channel_received" ON "channel_webhook_events" USING btree ("channel_id","received_at");--> statement-breakpoint
664
+ CREATE INDEX "idx_channel_webhook_events_status_received" ON "channel_webhook_events" USING btree ("status","received_at");--> statement-breakpoint
665
+ CREATE INDEX "idx_channel_webhook_events_event_type_received" ON "channel_webhook_events" USING btree ("event_type","received_at");--> statement-breakpoint
666
+ CREATE INDEX "idx_channel_webhook_events_external_event" ON "channel_webhook_events" USING btree ("external_event_id");--> statement-breakpoint
667
+ CREATE INDEX "idx_channels_created" ON "channels" USING btree ("created_at");--> statement-breakpoint
668
+ CREATE INDEX "idx_channels_kind_created" ON "channels" USING btree ("kind","created_at");--> statement-breakpoint
669
+ CREATE INDEX "idx_channels_status_created" ON "channels" USING btree ("status","created_at");--> statement-breakpoint
670
+ CREATE INDEX "idx_channel_reconciliation_items_updated" ON "channel_reconciliation_items" USING btree ("updated_at");--> statement-breakpoint
671
+ CREATE INDEX "idx_channel_reconciliation_items_run_updated" ON "channel_reconciliation_items" USING btree ("reconciliation_run_id","updated_at");--> statement-breakpoint
672
+ CREATE INDEX "idx_channel_reconciliation_items_booking_link_updated" ON "channel_reconciliation_items" USING btree ("booking_link_id","updated_at");--> statement-breakpoint
673
+ CREATE INDEX "idx_channel_reconciliation_items_booking_updated" ON "channel_reconciliation_items" USING btree ("booking_id","updated_at");--> statement-breakpoint
674
+ CREATE INDEX "idx_channel_reconciliation_items_issue_updated" ON "channel_reconciliation_items" USING btree ("issue_type","updated_at");--> statement-breakpoint
675
+ CREATE INDEX "idx_channel_reconciliation_items_resolution_updated" ON "channel_reconciliation_items" USING btree ("resolution_status","updated_at");--> statement-breakpoint
676
+ CREATE INDEX "idx_channel_reconciliation_runs_updated" ON "channel_reconciliation_runs" USING btree ("updated_at");--> statement-breakpoint
677
+ CREATE INDEX "idx_channel_reconciliation_runs_channel_updated" ON "channel_reconciliation_runs" USING btree ("channel_id","updated_at");--> statement-breakpoint
678
+ CREATE INDEX "idx_channel_reconciliation_runs_contract_updated" ON "channel_reconciliation_runs" USING btree ("contract_id","updated_at");--> statement-breakpoint
679
+ CREATE INDEX "idx_channel_reconciliation_runs_status_updated" ON "channel_reconciliation_runs" USING btree ("status","updated_at");--> statement-breakpoint
680
+ CREATE INDEX "idx_channel_remittance_exceptions_updated" ON "channel_remittance_exceptions" USING btree ("updated_at");--> statement-breakpoint
681
+ CREATE INDEX "idx_channel_remittance_exceptions_channel_updated" ON "channel_remittance_exceptions" USING btree ("channel_id","updated_at");--> statement-breakpoint
682
+ CREATE INDEX "idx_channel_remittance_exceptions_settlement_item_updated" ON "channel_remittance_exceptions" USING btree ("settlement_item_id","updated_at");--> statement-breakpoint
683
+ CREATE INDEX "idx_channel_remittance_exceptions_reconciliation_item_updated" ON "channel_remittance_exceptions" USING btree ("reconciliation_item_id","updated_at");--> statement-breakpoint
684
+ CREATE INDEX "idx_channel_remittance_exceptions_status_updated" ON "channel_remittance_exceptions" USING btree ("status","updated_at");--> statement-breakpoint
685
+ CREATE INDEX "idx_channel_settlement_approvals_updated" ON "channel_settlement_approvals" USING btree ("updated_at");--> statement-breakpoint
686
+ CREATE INDEX "idx_channel_settlement_approvals_run_updated" ON "channel_settlement_approvals" USING btree ("settlement_run_id","updated_at");--> statement-breakpoint
687
+ CREATE INDEX "idx_channel_settlement_approvals_status_updated" ON "channel_settlement_approvals" USING btree ("status","updated_at");--> statement-breakpoint
688
+ CREATE INDEX "idx_channel_settlement_items_updated" ON "channel_settlement_items" USING btree ("updated_at");--> statement-breakpoint
689
+ CREATE INDEX "idx_channel_settlement_items_run_updated" ON "channel_settlement_items" USING btree ("settlement_run_id","updated_at");--> statement-breakpoint
690
+ CREATE INDEX "idx_channel_settlement_items_booking_link_updated" ON "channel_settlement_items" USING btree ("booking_link_id","updated_at");--> statement-breakpoint
691
+ CREATE INDEX "idx_channel_settlement_items_booking_updated" ON "channel_settlement_items" USING btree ("booking_id","updated_at");--> statement-breakpoint
692
+ CREATE INDEX "idx_channel_settlement_items_status_updated" ON "channel_settlement_items" USING btree ("status","updated_at");--> statement-breakpoint
693
+ CREATE INDEX "idx_channel_settlement_runs_updated" ON "channel_settlement_runs" USING btree ("updated_at");--> statement-breakpoint
694
+ CREATE INDEX "idx_channel_settlement_runs_channel_updated" ON "channel_settlement_runs" USING btree ("channel_id","updated_at");--> statement-breakpoint
695
+ CREATE INDEX "idx_channel_settlement_runs_contract_updated" ON "channel_settlement_runs" USING btree ("contract_id","updated_at");--> statement-breakpoint
696
+ CREATE INDEX "idx_channel_settlement_runs_status_updated" ON "channel_settlement_runs" USING btree ("status","updated_at");--> statement-breakpoint
697
+ CREATE INDEX "idx_channel_settlement_runs_period" ON "channel_settlement_runs" USING btree ("period_start","period_end");--> statement-breakpoint
698
+ CREATE INDEX "idx_channel_inventory_allotment_targets_updated" ON "channel_inventory_allotment_targets" USING btree ("updated_at");--> statement-breakpoint
699
+ CREATE INDEX "idx_channel_inventory_allotment_targets_allotment_updated" ON "channel_inventory_allotment_targets" USING btree ("allotment_id","updated_at");--> statement-breakpoint
700
+ CREATE INDEX "idx_channel_inventory_allotment_targets_slot_updated" ON "channel_inventory_allotment_targets" USING btree ("slot_id","updated_at");--> statement-breakpoint
701
+ CREATE INDEX "idx_channel_inventory_allotment_targets_start_time_updated" ON "channel_inventory_allotment_targets" USING btree ("start_time_id","updated_at");--> statement-breakpoint
702
+ CREATE INDEX "idx_channel_inventory_allotment_targets_date_updated" ON "channel_inventory_allotment_targets" USING btree ("date_local","updated_at");--> statement-breakpoint
703
+ CREATE INDEX "idx_channel_inventory_allotment_targets_active_updated" ON "channel_inventory_allotment_targets" USING btree ("active","updated_at");--> statement-breakpoint
704
+ CREATE INDEX "idx_channel_inventory_allotments_updated" ON "channel_inventory_allotments" USING btree ("updated_at");--> statement-breakpoint
705
+ CREATE INDEX "idx_channel_inventory_allotments_channel_updated" ON "channel_inventory_allotments" USING btree ("channel_id","updated_at");--> statement-breakpoint
706
+ CREATE INDEX "idx_channel_inventory_allotments_contract_updated" ON "channel_inventory_allotments" USING btree ("contract_id","updated_at");--> statement-breakpoint
707
+ CREATE INDEX "idx_channel_inventory_allotments_product_updated" ON "channel_inventory_allotments" USING btree ("product_id","updated_at");--> statement-breakpoint
708
+ CREATE INDEX "idx_channel_inventory_allotments_option_updated" ON "channel_inventory_allotments" USING btree ("option_id","updated_at");--> statement-breakpoint
709
+ CREATE INDEX "idx_channel_inventory_allotments_start_time_updated" ON "channel_inventory_allotments" USING btree ("start_time_id","updated_at");--> statement-breakpoint
710
+ CREATE INDEX "idx_channel_inventory_allotments_active_updated" ON "channel_inventory_allotments" USING btree ("active","updated_at");--> statement-breakpoint
711
+ CREATE INDEX "idx_channel_inventory_release_executions_updated" ON "channel_inventory_release_executions" USING btree ("updated_at");--> statement-breakpoint
712
+ CREATE INDEX "idx_channel_inventory_release_executions_allotment_updated" ON "channel_inventory_release_executions" USING btree ("allotment_id","updated_at");--> statement-breakpoint
713
+ CREATE INDEX "idx_channel_inventory_release_executions_rule_updated" ON "channel_inventory_release_executions" USING btree ("release_rule_id","updated_at");--> statement-breakpoint
714
+ CREATE INDEX "idx_channel_inventory_release_executions_target_updated" ON "channel_inventory_release_executions" USING btree ("target_id","updated_at");--> statement-breakpoint
715
+ CREATE INDEX "idx_channel_inventory_release_executions_slot_updated" ON "channel_inventory_release_executions" USING btree ("slot_id","updated_at");--> statement-breakpoint
716
+ CREATE INDEX "idx_channel_inventory_release_executions_status_updated" ON "channel_inventory_release_executions" USING btree ("status","updated_at");--> statement-breakpoint
717
+ CREATE INDEX "idx_channel_inventory_release_rules_updated" ON "channel_inventory_release_rules" USING btree ("updated_at");--> statement-breakpoint
718
+ CREATE INDEX "idx_channel_inventory_release_rules_allotment_updated" ON "channel_inventory_release_rules" USING btree ("allotment_id","updated_at");--> statement-breakpoint
719
+ CREATE INDEX "idx_channel_inventory_release_rules_mode_updated" ON "channel_inventory_release_rules" USING btree ("release_mode","updated_at");--> statement-breakpoint
720
+ CREATE INDEX "idx_chan_avail_push_intents_requested" ON "channel_availability_push_intents" USING btree ("channel_id","requested_at");--> statement-breakpoint
721
+ CREATE INDEX "idx_chan_avail_push_intents_product" ON "channel_availability_push_intents" USING btree ("product_id","requested_at");--> statement-breakpoint
722
+ CREATE UNIQUE INDEX "uniq_chan_avail_push_intents_per_slot" ON "channel_availability_push_intents" USING btree ("channel_id","slot_id");--> statement-breakpoint
723
+ CREATE INDEX "idx_chan_content_push_intents_requested" ON "channel_content_push_intents" USING btree ("channel_id","requested_at");--> statement-breakpoint
724
+ CREATE UNIQUE INDEX "uniq_chan_content_push_intents_per_product" ON "channel_content_push_intents" USING btree ("channel_id","product_id");--> statement-breakpoint
725
+ CREATE INDEX "idx_supplier_availability_supplier_date" ON "supplier_availability" USING btree ("supplier_id","date");--> statement-breakpoint
726
+ CREATE INDEX "idx_supplier_availability_date" ON "supplier_availability" USING btree ("date");--> statement-breakpoint
727
+ CREATE INDEX "idx_supplier_contracts_supplier_created" ON "supplier_contracts" USING btree ("supplier_id","created_at");--> statement-breakpoint
728
+ CREATE INDEX "idx_supplier_contracts_status" ON "supplier_contracts" USING btree ("status");--> statement-breakpoint
729
+ CREATE UNIQUE INDEX "uq_supplier_directory_projections_supplier" ON "supplier_directory_projections" USING btree ("supplier_id");--> statement-breakpoint
730
+ CREATE INDEX "idx_supplier_notes_supplier_created" ON "supplier_notes" USING btree ("supplier_id","created_at");--> statement-breakpoint
731
+ CREATE INDEX "idx_supplier_rates_service_created" ON "supplier_rates" USING btree ("service_id","created_at");--> statement-breakpoint
732
+ CREATE INDEX "idx_supplier_rates_validity" ON "supplier_rates" USING btree ("valid_from","valid_to");--> statement-breakpoint
733
+ CREATE INDEX "idx_supplier_services_supplier_created" ON "supplier_services" USING btree ("supplier_id","created_at");--> statement-breakpoint
734
+ CREATE INDEX "idx_supplier_services_type" ON "supplier_services" USING btree ("service_type");--> statement-breakpoint
735
+ CREATE INDEX "idx_supplier_services_facility" ON "supplier_services" USING btree ("facility_id");--> statement-breakpoint
736
+ CREATE INDEX "idx_suppliers_created" ON "suppliers" USING btree ("created_at");--> statement-breakpoint
737
+ CREATE INDEX "idx_suppliers_type_created" ON "suppliers" USING btree ("type","created_at");--> statement-breakpoint
738
+ CREATE INDEX "idx_suppliers_status_created" ON "suppliers" USING btree ("status","created_at");--> statement-breakpoint
739
+ CREATE INDEX "idx_suppliers_primary_facility_created" ON "suppliers" USING btree ("primary_facility_id","created_at");
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1781947486784,
9
+ "tag": "0000_distribution_baseline",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/distribution",
3
- "version": "0.115.0",
3
+ "version": "0.116.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,21 +34,24 @@
34
34
  "drizzle-orm": "^0.45.2",
35
35
  "hono": "^4.12.10",
36
36
  "zod": "^4.3.6",
37
- "@voyant-travel/bookings": "^0.125.0",
38
- "@voyant-travel/catalog": "^0.123.0",
37
+ "@voyant-travel/bookings": "^0.126.0",
38
+ "@voyant-travel/catalog": "^0.124.1",
39
39
  "@voyant-travel/core": "^0.110.0",
40
- "@voyant-travel/db": "^0.108.3",
40
+ "@voyant-travel/db": "^0.108.4",
41
41
  "@voyant-travel/hono": "^0.112.2",
42
- "@voyant-travel/identity": "^0.125.0",
43
- "@voyant-travel/workflows": "^0.111.0",
42
+ "@voyant-travel/identity": "^0.126.1",
43
+ "@voyant-travel/workflows": "^0.111.2",
44
44
  "@voyant-travel/suppliers-contracts": "^0.104.4"
45
45
  },
46
46
  "devDependencies": {
47
+ "drizzle-kit": "^0.31.10",
47
48
  "typescript": "^6.0.2",
48
49
  "@voyant-travel/voyant-typescript-config": "^0.1.0"
49
50
  },
50
51
  "files": [
51
- "dist"
52
+ "dist",
53
+ "migrations/*.sql",
54
+ "migrations/meta/_journal.json"
52
55
  ],
53
56
  "publishConfig": {
54
57
  "access": "public"
@@ -69,7 +72,8 @@
69
72
  "lint": "biome check src/",
70
73
  "test": "vitest run",
71
74
  "build": "tsc -p tsconfig.json",
72
- "clean": "rm -rf dist tsconfig.tsbuildinfo"
75
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
76
+ "db:generate": "drizzle-kit generate --config=drizzle.migrations.config.ts --name=distribution_baseline && node ../../scripts/d2/guard-create-type.mjs ./migrations && node ../../scripts/d2/ensure-extensions.mjs ./migrations"
73
77
  },
74
78
  "main": "./dist/index.js",
75
79
  "types": "./dist/index.d.ts"