CREATE TABLE module_prefix_snapshot (
    tenant_id      TEXT NOT NULL REFERENCES tenant (id) ON DELETE CASCADE,
    module_id      TEXT NOT NULL REFERENCES module (id) ON DELETE CASCADE,
    input_hash     TEXT NOT NULL,
    collected_at   TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
    prefixes_json  TEXT NOT NULL DEFAULT '[]',
    PRIMARY KEY (tenant_id, module_id)
);

CREATE INDEX idx_module_prefix_snapshot_collected ON module_prefix_snapshot (collected_at);
