Lets BreakPilot staff open a product that is still disabled in the
catalogue (Werkmeister) for one tenant for a limited time, e.g. a seeded
staging tenant for portal#86, without a stage/prod divergence:
- Migration 0018: tenant_products.preview and preview_expires_at, kept
apart from a booking's expires_at.
- Entitlement check: a disabled product is allowed only under an active
preview (answer carries "preview": true); expiry is enforced at check
time (reason preview_expired). A leftover plain row of a product off
sale stays unknown_product.
- A real booking (ERP, trial, catalogue upsert) clears the preview and
its expiry, so it never cuts off a paid entitlement; a preview over a
booking is refused (409).
- Usage under a preview is accepted, tagged properties.preview=true and
kept out of the ERP outbox; claims list a preview product only while
it is active.
- Staff only, audited: POST /v1/admin/tenants/{id}/preview-grants
{product, expires_at ≤ 180 d}, DELETE …/preview-grants/{product}; a
named staff member (X-Staff-Subject) is required.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 lines
549 B
SQL
9 lines
549 B
SQL
-- Staff preview grants (tenant-registry ADR 0001 follow-up, Werkmeister W1):
|
|
-- a tenant may use a product that is not for sale yet (catalogue enabled =
|
|
-- false) while preview is true and preview_expires_at lies ahead. A real
|
|
-- booking clears both. Kept apart from expires_at, the booking's period end.
|
|
ALTER TABLE tenant_products
|
|
ADD COLUMN preview BOOLEAN NOT NULL DEFAULT FALSE,
|
|
ADD COLUMN preview_expires_at TIMESTAMPTZ,
|
|
ADD CONSTRAINT tenant_products_preview_expiry CHECK (preview = (preview_expires_at IS NOT NULL));
|