-- 034 — LEDGER TAKEABLE TAGGING (2026-07-31, specs/takeable-tagging.md)
--
-- Marks whether each ledger row's LOCKED price was one a bettor could actually
-- have taken, under the founder-ratified shape: a FLOOR on the minus side,
-- UNCAPPED on the plus side.
--
-- NOT the same as config/valueEngine.isTakeable (the -160..+200 PROMOTION band
-- used by the hero/board). A +400 prop is not promotable but IS takeable.
--
-- `takeable_floor` records the floor each row was tagged under, so a future
-- re-derivation (the floor is POLICY, not derived — see C1, 2026-07-30) can
-- re-tag safely without guessing what standard a row was judged by.
--
-- Additive only: nullable columns, no backfill of any existing value, nothing
-- deleted, nothing re-settled. NULL takeable = "no locked price to judge",
-- which is an honest absence, not false.

ALTER TABLE ledger_entries
  ADD COLUMN IF NOT EXISTS takeable       boolean,
  ADD COLUMN IF NOT EXISTS takeable_floor numeric;

COMMENT ON COLUMN ledger_entries.takeable IS
  'Locked price >= the policy floor (minus side), uncapped plus. NULL = no locked price. NOT the promotion band.';
COMMENT ON COLUMN ledger_entries.takeable_floor IS
  'The policy floor (American odds) this row was tagged under. Policy, not derived — see specs/takeable-tagging.md.';

CREATE INDEX IF NOT EXISTS idx_ledger_takeable
  ON ledger_entries (sport, takeable) WHERE user_id IS NULL;
