create table shipments (
    id bigint generated always as identity primary key,
    external_id text not null unique,
    status text not null check (status in ('booked', 'in_transit')),
    booked_at timestamptz not null
);

create table shipment_events (
    shipment_id bigint not null references shipments (id) on delete cascade,
    sequence integer not null check (sequence > 0),
    event_type text not null,
    occurred_at timestamptz not null,
    primary key (shipment_id, sequence)
);

create table recovery_ledger (
    sequence bigint primary key,
    external_id text not null unique,
    committed_at timestamptz not null
);
