container
Order Database
PostgreSQL database that is the system of record for orders and their items.
Databasepostgres@16Residency: eu-west-1Retention: 7yAccess Mode: readWrite
What is this?
The Order Database is the authoritative store for orders at Acme Inc. The Order ServiceOrder ServiceServicev1.0.0The system of record for orders. Creates and cancels orders, serves order lookups, and publishes events as orders move t...Publishesorder-created, order-completed +1Subscribescreate-order, cancel-order +1APIsAsyncAPIOwnerordering-platformMapRepoView docs reads from and writes to it as orders are created, cancelled and completed.
What does it store?
- Orders — one row per order: id, customer, status, total and timestamps.
- Order Items — one row per item in an order: product, quantity and unit price.
Schema
-- Order Database — system of record for orders
CREATE TABLE orders ( order_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), cart_id UUID, customer_id UUID NOT NULL, status TEXT NOT NULL DEFAULT 'CREATED' CHECK (status IN ('CREATED', 'COMPLETED', 'CANCELLED')), total_cents INTEGER NOT NULL CHECK (total_cents >= 0), currency CHAR(3) NOT NULL DEFAULT 'USD', created_at TIMESTAMPTZ NOT NULL DEFAULT now(), updated_at TIMESTAMPTZ NOT NULL DEFAULT now());
CREATE TABLE order_items ( order_id UUID NOT NULL REFERENCES orders (order_id) ON DELETE CASCADE, product_id UUID NOT NULL, quantity INTEGER NOT NULL CHECK (quantity > 0), unit_price_cents INTEGER NOT NULL CHECK (unit_price_cents >= 0), PRIMARY KEY (order_id, product_id));
CREATE INDEX idx_orders_customer ON orders (customer_id);CREATE INDEX idx_orders_status ON orders (status);Retention
Orders are financial records and are retained for 7 years (see frontmatter) to meet accounting and audit requirements.