Changes between Version 1 and Version 2 of AdvancedDatabaseDevelopment


Ignore:
Timestamp:
08/30/26 00:27:31 (12 days ago)
Author:
236021
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedDatabaseDevelopment

    v1 v2  
    458458
    459459{{{
    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
    462461CREATE OR REPLACE FUNCTION t1_billing_line_item_changed()
    463462RETURNS TRIGGER
     
    563562ALTER TABLE lab_tests ALTER COLUMN cost TYPE non_negative_cost USING cost::non_negative_cost;
    564563ALTER 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 these
    567 -- 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}$';
    572564}}}
    573565