import type { PoolClient } from 'pg'; /** * Product recommendations (related products + frequently bought together) — * schema foundation. See specifications/05-related-products-cross-sell-specification.md § 5. * * `product_link` holds manually curated product-to-product links. Links are * directional (A→B does not imply B→A); `type` accepts 'upsell' purely so a * future upsell feature needs no migration (spec § 3). `sort_order` is the * pinning order of the manual prefix in the resolution waterfall (§ 6.3). * * `product_stat` / `product_relation` / `product_stat_meta` are REBUILT * WHOLESALE by the nightly recompute job (§ 7.3) — no incremental writes, no * data migration here (§ 5.5: backfill is the job's first run, deliberately * not done in-migration so upgrades never block on a large order_item table). * `product_id` in the stats tables is always a variant-group REPRESENTATIVE * (§ 7.2: MIN(product_id) of the group, or the product's own id). CASCADE FKs * self-heal on product deletion — the next nightly run re-elects. * `product_relation` stores directed rows (both directions), so the composite * PK doubles as the per-anchor serving index. Counts only — confidence and * lift are DERIVED at read time (§ 5.2 / D2); a stored ratio would be stale * after every order. * * The `product_stat_meta` seed row means "never computed" is a readable state * (computed_at NULL) rather than a missing row — the admin status line * (§ 10.1) and the lift denominator join (§ 7.4) both rely on the row * existing. * * `product.category_id` got its FK in Version-1.0.2 WITHOUT an index; the * same-category rule (§ 6.1) puts that lookup on every PDP, hence * PRODUCT_CATEGORY_ID_INDEX here. `variant_group_id` is already covered by * "FK_PRODUCT_VARIANT_GROUP" (Version-1.0.0) — do not duplicate it. * * The mode/rules columns ride the existing product/category PATCH because * `given()` keeps real columns (§ 5.3). No `default` keywords exist for them * in the AJV schemas on purpose: getAjv() runs useDefaults:'empty', so a * schema default would be INJECTED into partial PATCH payloads and silently * reset stored modes. */ declare const _default: (connection: PoolClient) => Promise; export default _default;