CREATE TABLE market_subscriptions (
    id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    instrument_id INTEGER NOT NULL REFERENCES instruments(id),
    sub_kind TEXT NOT NULL,  -- 'PublicTrades', 'OrderBooksL1', etc.
    active BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    UNIQUE (instrument_id, sub_kind)
);

CREATE INDEX idx_market_subscriptions_active ON market_subscriptions(active) WHERE active = true;
