Changes between Version 1 and Version 2 of AdvancedDatabaseDevelopment
- Timestamp:
- 08/30/26 00:27:31 (12 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AdvancedDatabaseDevelopment
v1 v2 458 458 459 459 {{{ 460 -- one shared trigger function, reused for both billing_procedures and billing_lab_tests 461 -- (both tables have a bill_id column, so NEW.bill_id / OLD.bill_id works either way) 460 462 461 CREATE OR REPLACE FUNCTION t1_billing_line_item_changed() 463 462 RETURNS TRIGGER … … 563 562 ALTER TABLE lab_tests ALTER COLUMN cost TYPE non_negative_cost USING cost::non_negative_cost; 564 563 ALTER TABLE billing ALTER COLUMN total_cost TYPE non_negative_cost USING total_cost::non_negative_cost; 565 566 -- run these BEFORE altering embg / email / phone columns — every one of these567 -- should return ZERO rows, otherwise the corresponding ALTER will fail:568 -- SELECT patient_id, embg FROM patients WHERE embg !~ '^\d{13}$';569 -- SELECT doctor_id, email_address FROM doctors WHERE email_address !~ '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$';570 -- SELECT patient_id, email_address FROM patients WHERE email_address IS NOT NULL AND email_address !~ '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$';571 -- SELECT patient_id, phone_number FROM patients WHERE phone_number IS NOT NULL AND phone_number !~ '^\+?[\d\s\-().]{7,20}$';572 564 }}} 573 565
