CREATE TABLE IF NOT EXISTS industry_profiles (
code VARCHAR(80) PRIMARY KEY,
name VARCHAR(160) NOT NULL,
sort_order INT NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT TRUE
);
CREATE TABLE IF NOT EXISTS tenant_industry_profiles (
tenant_id CHAR(36) NOT NULL,
industry_code VARCHAR(80) NOT NULL,
created_at DATETIME NOT NULL,
PRIMARY KEY (tenant_id, industry_code),
CONSTRAINT tenant_industry_profiles_tenant_fk FOREIGN KEY (tenant_id) REFERENCES tenants(id),
CONSTRAINT tenant_industry_profiles_industry_fk FOREIGN KEY (industry_code) REFERENCES industry_profiles(code)
);
INSERT INTO industry_profiles (code, name, sort_order, is_active) VALUES
('handwerk', 'Handwerk', 10, TRUE),
('bau_montage', 'Bau/Montage', 20, TRUE),
('containerdienst', 'Containerdienst', 30, TRUE),
('entsorgung_recycling', 'Entsorgung/Recycling', 40, TRUE),
('leckortung_rohrbruch', 'Leckortung/Rohrbruch', 50, TRUE),
('facility_services', 'Facility Services', 60, TRUE),
('sonstige_technische_dienste', 'Sonstige technische Dienste', 70, TRUE)
ON DUPLICATE KEY UPDATE name = VALUES(name), sort_order = VALUES(sort_order), is_active = VALUES(is_active);
