CREATE TABLE IF NOT EXISTS patient_billing_rates (
 id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
 patient_id BIGINT UNSIGNED NOT NULL,
 service_id BIGINT UNSIGNED NOT NULL,
 rate DECIMAL(12,2) NOT NULL,
 label VARCHAR(100) NULL,
 created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
 updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 UNIQUE KEY uq_patient_service_rate (patient_id,service_id),
 KEY idx_patient_billing_rates_patient (patient_id),
 CONSTRAINT fk_pbr_patient FOREIGN KEY (patient_id) REFERENCES patients(id) ON DELETE CASCADE,
 CONSTRAINT fk_pbr_service FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE RESTRICT
);
