container
Promotion Database
PostgreSQL store of promotion and discount rules.
Databasepostgres@16Residency: eu-west-1Retention: indefiniteAccess Mode: readWrite
What is this?
The Promotion Database holds the promotion and discount rules that the Promotion ServicePromotion ServiceServicev1.0.0Evaluates promotion rules and calculates the discount that applies to a cart. Receives discount requests and publishes t...Publishesdiscount-calculatedSubscribescalculate-discountOwnershopping-platformMapRepoView docs evaluates when pricing a cart. It is the source of truth for what promotions exist, who they apply to, and when they are valid.
What does it store?
- Promotions — one row per promotion: code, type (percentage / fixed amount), value, and validity window.
- Eligibility rules — the conditions under which a promotion applies (minimum spend, customer segment, etc.).
Schema
-- Promotion Database — system of record for promotion and discount rules
CREATE TABLE promotions ( promotion_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), code TEXT NOT NULL UNIQUE, description TEXT, type TEXT NOT NULL CHECK (type IN ('PERCENTAGE', 'FIXED_AMOUNT')), value INTEGER NOT NULL CHECK (value >= 0), starts_at TIMESTAMPTZ NOT NULL, ends_at TIMESTAMPTZ, active BOOLEAN NOT NULL DEFAULT true);
CREATE TABLE eligibility_rules ( promotion_id UUID NOT NULL REFERENCES promotions (promotion_id) ON DELETE CASCADE, min_spend_cents INTEGER CHECK (min_spend_cents >= 0), customer_segment TEXT, PRIMARY KEY (promotion_id));
CREATE INDEX idx_promotions_active ON promotions (active) WHERE active = true;Access patterns
- The Promotion ServicePromotion ServiceServicev1.0.0
Evaluates promotion rules and calculates the discount that applies to a cart. Receives discount requests and publishes t...Publishesdiscount-calculatedSubscribescalculate-discountOwnershopping-platformMapRepoView docs reads rules when handling Calculate DiscountCalculate DiscountCommandv1.0.0Command to calculate the discount that applies to a cart. Ownershopping-platformSchemaMapView docs.
- Rules are managed by the promotions team and change infrequently relative to read volume.