CREATE TABLE channel_config_snapshots (
    id          TEXT    PRIMARY KEY NOT NULL,
    channel_id  TEXT    NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
    config_json TEXT    NOT NULL,
    version_num INTEGER NOT NULL,
    label       TEXT,
    created_at  TEXT    NOT NULL,
    UNIQUE (channel_id, version_num)
);

CREATE INDEX idx_config_snapshots_channel
    ON channel_config_snapshots(channel_id, version_num DESC);
