-- Generic, game-scoped OPAQUE extension storage.
--
-- Core persists, versions, associates (to a canonical entity + a server-computed
-- fingerprint), and enforces generic safety bounds on these bytes — but NEVER
-- interprets them. A game adapter owns the payload's schema and meaning. This is
-- how a game keeps wire-only round-trip state (e.g. FIFA 17 squad custom[]/
-- kicktakers/kitNumber) durable and atomic with its canonical entity without
-- leaking game-specific columns into generic Core.
--
-- Scope key: (game_id, entity_kind, entity_id, namespace). `namespace` is an
-- opaque adapter key (e.g. "fifa17.squad.v1"); `schema_version` is the adapter's
-- payload version (distinct from this table's storage schema).
CREATE TABLE IF NOT EXISTS game_entity_ext (
    game_id               TEXT    NOT NULL,
    entity_kind           TEXT    NOT NULL,
    entity_id             TEXT    NOT NULL,
    namespace             TEXT    NOT NULL,
    schema_version        INTEGER NOT NULL,
    canonical_fingerprint TEXT    NOT NULL,
    payload               TEXT    NOT NULL,
    updated_at            TEXT    NOT NULL,
    PRIMARY KEY (game_id, entity_kind, entity_id, namespace)
);
