-- Add human-readable identity and provenance metadata to strategies.
-- name + version form a stable lineage key: mutating a strategy increments
-- version while keeping the same name.  The hash column remains the
-- content-dedup key used by API-driven upserts.
--
-- All columns are nullable so existing hash-only rows are not affected.

ALTER TABLE strategies
    ADD COLUMN name        TEXT,
    ADD COLUMN version     INTEGER NOT NULL DEFAULT 1,
    ADD COLUMN description TEXT;

-- Partial unique index: enforced only when name is set.
-- Allows multiple anonymous (name IS NULL) rows while ensuring named
-- strategies are unique within a lineage.
CREATE UNIQUE INDEX idx_strategies_name_version
    ON strategies (name, version) WHERE name IS NOT NULL;
