-- Migration 084: Modul-Registrierung für Rechte & Kontingente (Registry-first)
-- capabilities/features mit module=NULL = Legacy-Katalog-Seed (nicht in Admin-Matrix).
-- module IS NOT NULL = vom Modul bei Implementierung registriert.

ALTER TABLE capabilities
    ADD COLUMN IF NOT EXISTS module TEXT;

ALTER TABLE features
    ADD COLUMN IF NOT EXISTS module TEXT;

CREATE INDEX IF NOT EXISTS idx_capabilities_module
    ON capabilities(module) WHERE module IS NOT NULL AND active = true;

CREATE INDEX IF NOT EXISTS idx_features_module
    ON features(module) WHERE module IS NOT NULL AND active = true;
