-- ============================================================================
-- Copyright (C) 2026 Alles Watt lauft
-- Keys for llx_kundenkarte_busbar_type
-- ============================================================================

ALTER TABLE llx_kundenkarte_busbar_type ADD INDEX idx_busbar_type_ref (ref);
ALTER TABLE llx_kundenkarte_busbar_type ADD INDEX idx_busbar_type_system (fk_system);
ALTER TABLE llx_kundenkarte_busbar_type ADD INDEX idx_busbar_type_active (active);
ALTER TABLE llx_kundenkarte_busbar_type ADD UNIQUE INDEX uk_busbar_type_ref_system (ref, fk_system);

ALTER TABLE llx_kundenkarte_busbar_type ADD CONSTRAINT fk_busbar_type_system
    FOREIGN KEY (fk_system) REFERENCES llx_c_kundenkarte_anlage_system(rowid);
ALTER TABLE llx_kundenkarte_busbar_type ADD CONSTRAINT fk_busbar_type_product
    FOREIGN KEY (fk_product) REFERENCES llx_product(rowid) ON DELETE SET NULL;
