BEGIN;
DELETE FROM change_table WHERE _rowid = 1;
INSERT INTO change_table(_rowid, table_name) VALUES (1, 'BEXIgnore');
DELETE FROM change_table WHERE _rowid = 32;
INSERT INTO change_table(_rowid, table_name) VALUES (32, 'BIUser');
DELETE FROM change_table WHERE _rowid = 2;
INSERT INTO change_table(_rowid, table_name) VALUES (2, 'Category');
DELETE FROM change_table WHERE _rowid = 3;
INSERT INTO change_table(_rowid, table_name) VALUES (3, 'Client');
DELETE FROM change_table WHERE _rowid = 4;
INSERT INTO change_table(_rowid, table_name) VALUES (4, 'ClientABLink');
DELETE FROM change_table WHERE _rowid = 5;
INSERT INTO change_table(_rowid, table_name) VALUES (5, 'ClientCategory');
DELETE FROM change_table WHERE _rowid = 6;
INSERT INTO change_table(_rowid, table_name) VALUES (6, 'ClientPhoto');
DELETE FROM change_table WHERE _rowid = 46;
INSERT INTO change_table(_rowid, table_name) VALUES (46, 'ConnectorMap');
DELETE FROM change_table WHERE _rowid = 7;
INSERT INTO change_table(_rowid, table_name) VALUES (7, 'ConsolidatedTax');
DELETE FROM change_table WHERE _rowid = 35;
INSERT INTO change_table(_rowid, table_name) VALUES (35, 'Currency');
DELETE FROM change_table WHERE _rowid = 8;
INSERT INTO change_table(_rowid, table_name) VALUES (8, 'Estimate');
DELETE FROM change_table WHERE _rowid = 36;
INSERT INTO change_table(_rowid, table_name) VALUES (36, 'EstimateHtml');
DELETE FROM change_table WHERE _rowid = 9;
INSERT INTO change_table(_rowid, table_name) VALUES (9, 'EstimateSlip');
DELETE FROM change_table WHERE _rowid = 37;
INSERT INTO change_table(_rowid, table_name) VALUES (37, 'Extra');
DELETE FROM change_table WHERE _rowid = 10;
INSERT INTO change_table(_rowid, table_name) VALUES (10, 'ExtraFieldNames');
DELETE FROM change_table WHERE _rowid = 45;
INSERT INTO change_table(_rowid, table_name) VALUES (45, 'Identity');
DELETE FROM change_table WHERE _rowid = 11;
INSERT INTO change_table(_rowid, table_name) VALUES (11, 'Invoice');
DELETE FROM change_table WHERE _rowid = 34;
INSERT INTO change_table(_rowid, table_name) VALUES (34, 'InvoiceHtml');
DELETE FROM change_table WHERE _rowid = 12;
INSERT INTO change_table(_rowid, table_name) VALUES (12, 'MCUserDefaultsStorage');
DELETE FROM change_table WHERE _rowid = 13;
INSERT INTO change_table(_rowid, table_name) VALUES (13, 'Note');
DELETE FROM change_table WHERE _rowid = 14;
INSERT INTO change_table(_rowid, table_name) VALUES (14, 'Payment');
DELETE FROM change_table WHERE _rowid = 15;
INSERT INTO change_table(_rowid, table_name) VALUES (15, 'PaymentInvoiceEntry');
DELETE FROM change_table WHERE _rowid = 16;
INSERT INTO change_table(_rowid, table_name) VALUES (16, 'PaymentMethodType');
DELETE FROM change_table WHERE _rowid = 17;
INSERT INTO change_table(_rowid, table_name) VALUES (17, 'ProFormaInvoice');
DELETE FROM change_table WHERE _rowid = 18;
INSERT INTO change_table(_rowid, table_name) VALUES (18, 'Project');
DELETE FROM change_table WHERE _rowid = 19;
INSERT INTO change_table(_rowid, table_name) VALUES (19, 'ProjectStage');
DELETE FROM change_table WHERE _rowid = 20;
INSERT INTO change_table(_rowid, table_name) VALUES (20, 'ProjectState');
DELETE FROM change_table WHERE _rowid = 41;
INSERT INTO change_table(_rowid, table_name) VALUES (41, 'ProjectUser');
DELETE FROM change_table WHERE _rowid = 21;
INSERT INTO change_table(_rowid, table_name) VALUES (21, 'RecurringInvoice');
DELETE FROM change_table WHERE _rowid = 40;
INSERT INTO change_table(_rowid, table_name) VALUES (40, 'ReportTemplate');
DELETE FROM change_table WHERE _rowid = 44;
INSERT INTO change_table(_rowid, table_name) VALUES (44, 'ReportTemplatePreference');
DELETE FROM change_table WHERE _rowid = 22;
INSERT INTO change_table(_rowid, table_name) VALUES (22, 'Retainer');
DELETE FROM change_table WHERE _rowid = 23;
INSERT INTO change_table(_rowid, table_name) VALUES (23, 'SlipConflict');
DELETE FROM change_table WHERE _rowid = 24;
INSERT INTO change_table(_rowid, table_name) VALUES (24, 'SlipTemplate');
DELETE FROM change_table WHERE _rowid = 25;
INSERT INTO change_table(_rowid, table_name) VALUES (25, 'Statement');
DELETE FROM change_table WHERE _rowid = 26;
INSERT INTO change_table(_rowid, table_name) VALUES (26, 'Tax');
DELETE FROM change_table WHERE _rowid = 27;
INSERT INTO change_table(_rowid, table_name) VALUES (27, 'TaxConsolidatedTaxEntry');
DELETE FROM change_table WHERE _rowid = 28;
INSERT INTO change_table(_rowid, table_name) VALUES (28, 'TimeEntry');
DELETE FROM change_table WHERE _rowid = 29;
INSERT INTO change_table(_rowid, table_name) VALUES (29, 'TimeSlip');
DELETE FROM change_table WHERE _rowid = 30;
INSERT INTO change_table(_rowid, table_name) VALUES (30, 'TimeSlipType');
DELETE FROM change_table WHERE _rowid = 31;
INSERT INTO change_table(_rowid, table_name) VALUES (31, 'URLReference');
CREATE OR REPLACE FUNCTION mc_bexignore_change_log() RETURNS TRIGGER AS $mc_bexignore_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.foreignAppEntityName != OLD.foreignAppEntityName) OR
            ((NEW.foreignAppEntityName IS NULL) AND (OLD.foreignAppEntityName IS NOT NULL)) OR
            ((NEW.foreignAppEntityName IS NOT NULL) AND (OLD.foreignAppEntityName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppEntityName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppImportID != OLD.foreignAppImportID) OR
            ((NEW.foreignAppImportID IS NULL) AND (OLD.foreignAppImportID IS NOT NULL)) OR
            ((NEW.foreignAppImportID IS NOT NULL) AND (OLD.foreignAppImportID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppImportID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppName != OLD.foreignAppName) OR
            ((NEW.foreignAppName IS NULL) AND (OLD.foreignAppName IS NOT NULL)) OR
            ((NEW.foreignAppName IS NOT NULL) AND (OLD.foreignAppName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppName'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_bexignore_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS BEXIgnore_change_log_trigger ON BEXIgnore;
CREATE TRIGGER BEXIgnore_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON BEXIgnore FOR EACH ROW EXECUTE PROCEDURE mc_bexignore_change_log(1);
CREATE OR REPLACE FUNCTION mc_biuser_change_log() RETURNS TRIGGER AS $mc_biuser_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.active != OLD.active) OR
            ((NEW.active IS NULL) AND (OLD.active IS NOT NULL)) OR
            ((NEW.active IS NOT NULL) AND (OLD.active IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'active'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.password != OLD.password) OR
            ((NEW.password IS NULL) AND (OLD.password IS NOT NULL)) OR
            ((NEW.password IS NOT NULL) AND (OLD.password IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'password'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.canUseBillingsPro != OLD.canUseBillingsPro) OR
            ((NEW.canUseBillingsPro IS NULL) AND (OLD.canUseBillingsPro IS NOT NULL)) OR
            ((NEW.canUseBillingsPro IS NOT NULL) AND (OLD.canUseBillingsPro IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'canUseBillingsPro'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.canUseBillingsProTouch != OLD.canUseBillingsProTouch) OR
            ((NEW.canUseBillingsProTouch IS NULL) AND (OLD.canUseBillingsProTouch IS NOT NULL)) OR
            ((NEW.canUseBillingsProTouch IS NOT NULL) AND (OLD.canUseBillingsProTouch IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'canUseBillingsProTouch'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.canUsePunchcard != OLD.canUsePunchcard) OR
            ((NEW.canUsePunchcard IS NULL) AND (OLD.canUsePunchcard IS NOT NULL)) OR
            ((NEW.canUsePunchcard IS NOT NULL) AND (OLD.canUsePunchcard IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'canUsePunchcard'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.capability4 != OLD.capability4) OR
            ((NEW.capability4 IS NULL) AND (OLD.capability4 IS NOT NULL)) OR
            ((NEW.capability4 IS NOT NULL) AND (OLD.capability4 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'capability4'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.capability5 != OLD.capability5) OR
            ((NEW.capability5 IS NULL) AND (OLD.capability5 IS NOT NULL)) OR
            ((NEW.capability5 IS NOT NULL) AND (OLD.capability5 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'capability5'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.capability6 != OLD.capability6) OR
            ((NEW.capability6 IS NULL) AND (OLD.capability6 IS NOT NULL)) OR
            ((NEW.capability6 IS NOT NULL) AND (OLD.capability6 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'capability6'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.capability7 != OLD.capability7) OR
            ((NEW.capability7 IS NULL) AND (OLD.capability7 IS NOT NULL)) OR
            ((NEW.capability7 IS NOT NULL) AND (OLD.capability7 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'capability7'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.capability8 != OLD.capability8) OR
            ((NEW.capability8 IS NULL) AND (OLD.capability8 IS NOT NULL)) OR
            ((NEW.capability8 IS NOT NULL) AND (OLD.capability8 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'capability8'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_biuser_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS BIUser_change_log_trigger ON BIUser;
CREATE TRIGGER BIUser_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON BIUser FOR EACH ROW EXECUTE PROCEDURE mc_biuser_change_log(32);
CREATE OR REPLACE FUNCTION mc_category_change_log() RETURNS TRIGGER AS $mc_category_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_category_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Category_change_log_trigger ON Category;
CREATE TRIGGER Category_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Category FOR EACH ROW EXECUTE PROCEDURE mc_category_change_log(2);
CREATE OR REPLACE FUNCTION mc_client_change_log() RETURNS TRIGGER AS $mc_client_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.mileageDistance != OLD.mileageDistance) OR
            ((NEW.mileageDistance IS NULL) AND (OLD.mileageDistance IS NOT NULL)) OR
            ((NEW.mileageDistance IS NOT NULL) AND (OLD.mileageDistance IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'mileageDistance'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientNumber != OLD.clientNumber) OR
            ((NEW.clientNumber IS NULL) AND (OLD.clientNumber IS NOT NULL)) OR
            ((NEW.clientNumber IS NOT NULL) AND (OLD.clientNumber IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientNumber'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.company != OLD.company) OR
            ((NEW.company IS NULL) AND (OLD.company IS NOT NULL)) OR
            ((NEW.company IS NOT NULL) AND (OLD.company IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'company'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.email != OLD.email) OR
            ((NEW.email IS NULL) AND (OLD.email IS NOT NULL)) OR
            ((NEW.email IS NOT NULL) AND (OLD.email IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'email'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra1 != OLD.extra1) OR
            ((NEW.extra1 IS NULL) AND (OLD.extra1 IS NOT NULL)) OR
            ((NEW.extra1 IS NOT NULL) AND (OLD.extra1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra2 != OLD.extra2) OR
            ((NEW.extra2 IS NULL) AND (OLD.extra2 IS NOT NULL)) OR
            ((NEW.extra2 IS NOT NULL) AND (OLD.extra2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra3 != OLD.extra3) OR
            ((NEW.extra3 IS NULL) AND (OLD.extra3 IS NOT NULL)) OR
            ((NEW.extra3 IS NOT NULL) AND (OLD.extra3 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra3'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra4 != OLD.extra4) OR
            ((NEW.extra4 IS NULL) AND (OLD.extra4 IS NOT NULL)) OR
            ((NEW.extra4 IS NOT NULL) AND (OLD.extra4 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra4'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.firstName != OLD.firstName) OR
            ((NEW.firstName IS NULL) AND (OLD.firstName IS NOT NULL)) OR
            ((NEW.firstName IS NOT NULL) AND (OLD.firstName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'firstName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.hourlyRate != OLD.hourlyRate) OR
            ((NEW.hourlyRate IS NULL) AND (OLD.hourlyRate IS NOT NULL)) OR
            ((NEW.hourlyRate IS NOT NULL) AND (OLD.hourlyRate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'hourlyRate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.isCompany != OLD.isCompany) OR
            ((NEW.isCompany IS NULL) AND (OLD.isCompany IS NOT NULL)) OR
            ((NEW.isCompany IS NOT NULL) AND (OLD.isCompany IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'isCompany'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.lastName != OLD.lastName) OR
            ((NEW.lastName IS NULL) AND (OLD.lastName IS NOT NULL)) OR
            ((NEW.lastName IS NOT NULL) AND (OLD.lastName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'lastName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.mileageRate != OLD.mileageRate) OR
            ((NEW.mileageRate IS NULL) AND (OLD.mileageRate IS NOT NULL)) OR
            ((NEW.mileageRate IS NOT NULL) AND (OLD.mileageRate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'mileageRate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientCategoryID != OLD.clientCategoryID) OR
            ((NEW.clientCategoryID IS NULL) AND (OLD.clientCategoryID IS NOT NULL)) OR
            ((NEW.clientCategoryID IS NOT NULL) AND (OLD.clientCategoryID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientCategoryID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.balanceCached != OLD.balanceCached) OR
            ((NEW.balanceCached IS NULL) AND (OLD.balanceCached IS NOT NULL)) OR
            ((NEW.balanceCached IS NOT NULL) AND (OLD.balanceCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'balanceCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.retainersBalanceCached != OLD.retainersBalanceCached) OR
            ((NEW.retainersBalanceCached IS NULL) AND (OLD.retainersBalanceCached IS NOT NULL)) OR
            ((NEW.retainersBalanceCached IS NOT NULL) AND (OLD.retainersBalanceCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'retainersBalanceCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.unbilledAmountCached != OLD.unbilledAmountCached) OR
            ((NEW.unbilledAmountCached IS NULL) AND (OLD.unbilledAmountCached IS NOT NULL)) OR
            ((NEW.unbilledAmountCached IS NOT NULL) AND (OLD.unbilledAmountCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'unbilledAmountCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.incompleteAmountCached != OLD.incompleteAmountCached) OR
            ((NEW.incompleteAmountCached IS NULL) AND (OLD.incompleteAmountCached IS NOT NULL)) OR
            ((NEW.incompleteAmountCached IS NOT NULL) AND (OLD.incompleteAmountCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'incompleteAmountCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.addressCity != OLD.addressCity) OR
            ((NEW.addressCity IS NULL) AND (OLD.addressCity IS NOT NULL)) OR
            ((NEW.addressCity IS NOT NULL) AND (OLD.addressCity IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'addressCity'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.addressStreet != OLD.addressStreet) OR
            ((NEW.addressStreet IS NULL) AND (OLD.addressStreet IS NOT NULL)) OR
            ((NEW.addressStreet IS NOT NULL) AND (OLD.addressStreet IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'addressStreet'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.addressState != OLD.addressState) OR
            ((NEW.addressState IS NULL) AND (OLD.addressState IS NOT NULL)) OR
            ((NEW.addressState IS NOT NULL) AND (OLD.addressState IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'addressState'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.addressZIP != OLD.addressZIP) OR
            ((NEW.addressZIP IS NULL) AND (OLD.addressZIP IS NOT NULL)) OR
            ((NEW.addressZIP IS NOT NULL) AND (OLD.addressZIP IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'addressZIP'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.addressCountry != OLD.addressCountry) OR
            ((NEW.addressCountry IS NULL) AND (OLD.addressCountry IS NOT NULL)) OR
            ((NEW.addressCountry IS NOT NULL) AND (OLD.addressCountry IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'addressCountry'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.addressFormatted != OLD.addressFormatted) OR
            ((NEW.addressFormatted IS NULL) AND (OLD.addressFormatted IS NOT NULL)) OR
            ((NEW.addressFormatted IS NOT NULL) AND (OLD.addressFormatted IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'addressFormatted'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientPhotoID != OLD.clientPhotoID) OR
            ((NEW.clientPhotoID IS NULL) AND (OLD.clientPhotoID IS NOT NULL)) OR
            ((NEW.clientPhotoID IS NOT NULL) AND (OLD.clientPhotoID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientPhotoID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.currentCurrencyID != OLD.currentCurrencyID) OR
            ((NEW.currentCurrencyID IS NULL) AND (OLD.currentCurrencyID IS NOT NULL)) OR
            ((NEW.currentCurrencyID IS NOT NULL) AND (OLD.currentCurrencyID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'currentCurrencyID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.overdueAmountCached != OLD.overdueAmountCached) OR
            ((NEW.overdueAmountCached IS NULL) AND (OLD.overdueAmountCached IS NOT NULL)) OR
            ((NEW.overdueAmountCached IS NOT NULL) AND (OLD.overdueAmountCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'overdueAmountCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.overdueAmountValidUntilDate != OLD.overdueAmountValidUntilDate) OR
            ((NEW.overdueAmountValidUntilDate IS NULL) AND (OLD.overdueAmountValidUntilDate IS NOT NULL)) OR
            ((NEW.overdueAmountValidUntilDate IS NOT NULL) AND (OLD.overdueAmountValidUntilDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'overdueAmountValidUntilDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoiceTemplatePrefID != OLD.invoiceTemplatePrefID) OR
            ((NEW.invoiceTemplatePrefID IS NULL) AND (OLD.invoiceTemplatePrefID IS NOT NULL)) OR
            ((NEW.invoiceTemplatePrefID IS NOT NULL) AND (OLD.invoiceTemplatePrefID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoiceTemplatePrefID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.estimateTemplatePrefID != OLD.estimateTemplatePrefID) OR
            ((NEW.estimateTemplatePrefID IS NULL) AND (OLD.estimateTemplatePrefID IS NOT NULL)) OR
            ((NEW.estimateTemplatePrefID IS NOT NULL) AND (OLD.estimateTemplatePrefID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'estimateTemplatePrefID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.statementTemplatePrefID != OLD.statementTemplatePrefID) OR
            ((NEW.statementTemplatePrefID IS NULL) AND (OLD.statementTemplatePrefID IS NOT NULL)) OR
            ((NEW.statementTemplatePrefID IS NOT NULL) AND (OLD.statementTemplatePrefID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'statementTemplatePrefID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.taxNumber != OLD.taxNumber) OR
            ((NEW.taxNumber IS NULL) AND (OLD.taxNumber IS NOT NULL)) OR
            ((NEW.taxNumber IS NOT NULL) AND (OLD.taxNumber IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'taxNumber'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.billingIdentityID != OLD.billingIdentityID) OR
            ((NEW.billingIdentityID IS NULL) AND (OLD.billingIdentityID IS NOT NULL)) OR
            ((NEW.billingIdentityID IS NOT NULL) AND (OLD.billingIdentityID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'billingIdentityID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.prefix != OLD.prefix) OR
            ((NEW.prefix IS NULL) AND (OLD.prefix IS NOT NULL)) OR
            ((NEW.prefix IS NOT NULL) AND (OLD.prefix IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'prefix'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.suffix != OLD.suffix) OR
            ((NEW.suffix IS NULL) AND (OLD.suffix IS NOT NULL)) OR
            ((NEW.suffix IS NOT NULL) AND (OLD.suffix IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'suffix'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.middleName != OLD.middleName) OR
            ((NEW.middleName IS NULL) AND (OLD.middleName IS NOT NULL)) OR
            ((NEW.middleName IS NOT NULL) AND (OLD.middleName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'middleName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.nickName != OLD.nickName) OR
            ((NEW.nickName IS NULL) AND (OLD.nickName IS NOT NULL)) OR
            ((NEW.nickName IS NOT NULL) AND (OLD.nickName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'nickName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.jobTitle != OLD.jobTitle) OR
            ((NEW.jobTitle IS NULL) AND (OLD.jobTitle IS NOT NULL)) OR
            ((NEW.jobTitle IS NOT NULL) AND (OLD.jobTitle IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'jobTitle'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.department != OLD.department) OR
            ((NEW.department IS NULL) AND (OLD.department IS NOT NULL)) OR
            ((NEW.department IS NOT NULL) AND (OLD.department IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'department'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.formalGreeting != OLD.formalGreeting) OR
            ((NEW.formalGreeting IS NULL) AND (OLD.formalGreeting IS NOT NULL)) OR
            ((NEW.formalGreeting IS NOT NULL) AND (OLD.formalGreeting IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'formalGreeting'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_client_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Client_change_log_trigger ON Client;
CREATE TRIGGER Client_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Client FOR EACH ROW EXECUTE PROCEDURE mc_client_change_log(3);
CREATE OR REPLACE FUNCTION mc_clientablink_change_log() RETURNS TRIGGER AS $mc_clientablink_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.deviceUUID != OLD.deviceUUID) OR
            ((NEW.deviceUUID IS NULL) AND (OLD.deviceUUID IS NOT NULL)) OR
            ((NEW.deviceUUID IS NOT NULL) AND (OLD.deviceUUID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'deviceUUID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.abUUID != OLD.abUUID) OR
            ((NEW.abUUID IS NULL) AND (OLD.abUUID IS NOT NULL)) OR
            ((NEW.abUUID IS NOT NULL) AND (OLD.abUUID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'abUUID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.abAddressUUID != OLD.abAddressUUID) OR
            ((NEW.abAddressUUID IS NULL) AND (OLD.abAddressUUID IS NOT NULL)) OR
            ((NEW.abAddressUUID IS NOT NULL) AND (OLD.abAddressUUID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'abAddressUUID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.abEmailUUID != OLD.abEmailUUID) OR
            ((NEW.abEmailUUID IS NULL) AND (OLD.abEmailUUID IS NOT NULL)) OR
            ((NEW.abEmailUUID IS NOT NULL) AND (OLD.abEmailUUID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'abEmailUUID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_clientablink_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ClientABLink_change_log_trigger ON ClientABLink;
CREATE TRIGGER ClientABLink_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ClientABLink FOR EACH ROW EXECUTE PROCEDURE mc_clientablink_change_log(4);
CREATE OR REPLACE FUNCTION mc_clientcategory_change_log() RETURNS TRIGGER AS $mc_clientcategory_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.collapsed != OLD.collapsed) OR
            ((NEW.collapsed IS NULL) AND (OLD.collapsed IS NOT NULL)) OR
            ((NEW.collapsed IS NOT NULL) AND (OLD.collapsed IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'collapsed'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.orderNumber != OLD.orderNumber) OR
            ((NEW.orderNumber IS NULL) AND (OLD.orderNumber IS NOT NULL)) OR
            ((NEW.orderNumber IS NOT NULL) AND (OLD.orderNumber IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'orderNumber'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_clientcategory_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ClientCategory_change_log_trigger ON ClientCategory;
CREATE TRIGGER ClientCategory_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ClientCategory FOR EACH ROW EXECUTE PROCEDURE mc_clientcategory_change_log(5);
CREATE OR REPLACE FUNCTION mc_clientphoto_change_log() RETURNS TRIGGER AS $mc_clientphoto_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.imageData != OLD.imageData) OR
            ((NEW.imageData IS NULL) AND (OLD.imageData IS NOT NULL)) OR
            ((NEW.imageData IS NOT NULL) AND (OLD.imageData IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'imageData'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_clientphoto_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ClientPhoto_change_log_trigger ON ClientPhoto;
CREATE TRIGGER ClientPhoto_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ClientPhoto FOR EACH ROW EXECUTE PROCEDURE mc_clientphoto_change_log(6);
CREATE OR REPLACE FUNCTION mc_connectormap_change_log() RETURNS TRIGGER AS $mc_connectormap_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.foreignID != OLD.foreignID) OR
            ((NEW.foreignID IS NULL) AND (OLD.foreignID IS NOT NULL)) OR
            ((NEW.foreignID IS NOT NULL) AND (OLD.foreignID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignEntityType != OLD.foreignEntityType) OR
            ((NEW.foreignEntityType IS NULL) AND (OLD.foreignEntityType IS NOT NULL)) OR
            ((NEW.foreignEntityType IS NOT NULL) AND (OLD.foreignEntityType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignEntityType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignDatabase != OLD.foreignDatabase) OR
            ((NEW.foreignDatabase IS NULL) AND (OLD.foreignDatabase IS NOT NULL)) OR
            ((NEW.foreignDatabase IS NOT NULL) AND (OLD.foreignDatabase IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignDatabase'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppName != OLD.foreignAppName) OR
            ((NEW.foreignAppName IS NULL) AND (OLD.foreignAppName IS NOT NULL)) OR
            ((NEW.foreignAppName IS NOT NULL) AND (OLD.foreignAppName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.parentID != OLD.parentID) OR
            ((NEW.parentID IS NULL) AND (OLD.parentID IS NOT NULL)) OR
            ((NEW.parentID IS NOT NULL) AND (OLD.parentID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'parentID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.parentEntity != OLD.parentEntity) OR
            ((NEW.parentEntity IS NULL) AND (OLD.parentEntity IS NOT NULL)) OR
            ((NEW.parentEntity IS NOT NULL) AND (OLD.parentEntity IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'parentEntity'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.lastPushDate != OLD.lastPushDate) OR
            ((NEW.lastPushDate IS NULL) AND (OLD.lastPushDate IS NOT NULL)) OR
            ((NEW.lastPushDate IS NOT NULL) AND (OLD.lastPushDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'lastPushDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.lastPullDate != OLD.lastPullDate) OR
            ((NEW.lastPullDate IS NULL) AND (OLD.lastPullDate IS NOT NULL)) OR
            ((NEW.lastPullDate IS NOT NULL) AND (OLD.lastPullDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'lastPullDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userID != OLD.userID) OR
            ((NEW.userID IS NULL) AND (OLD.userID IS NOT NULL)) OR
            ((NEW.userID IS NOT NULL) AND (OLD.userID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_connectormap_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ConnectorMap_change_log_trigger ON ConnectorMap;
CREATE TRIGGER ConnectorMap_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ConnectorMap FOR EACH ROW EXECUTE PROCEDURE mc_connectormap_change_log(46);
CREATE OR REPLACE FUNCTION mc_consolidatedtax_change_log() RETURNS TRIGGER AS $mc_consolidatedtax_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.active != OLD.active) OR
            ((NEW.active IS NULL) AND (OLD.active IS NOT NULL)) OR
            ((NEW.active IS NOT NULL) AND (OLD.active IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'active'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.atomic != OLD.atomic) OR
            ((NEW.atomic IS NULL) AND (OLD.atomic IS NOT NULL)) OR
            ((NEW.atomic IS NOT NULL) AND (OLD.atomic IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'atomic'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.parentConsolidatedTaxID != OLD.parentConsolidatedTaxID) OR
            ((NEW.parentConsolidatedTaxID IS NULL) AND (OLD.parentConsolidatedTaxID IS NOT NULL)) OR
            ((NEW.parentConsolidatedTaxID IS NOT NULL) AND (OLD.parentConsolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'parentConsolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_consolidatedtax_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ConsolidatedTax_change_log_trigger ON ConsolidatedTax;
CREATE TRIGGER ConsolidatedTax_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ConsolidatedTax FOR EACH ROW EXECUTE PROCEDURE mc_consolidatedtax_change_log(7);
CREATE OR REPLACE FUNCTION mc_currency_change_log() RETURNS TRIGGER AS $mc_currency_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.currencyCode != OLD.currencyCode) OR
            ((NEW.currencyCode IS NULL) AND (OLD.currencyCode IS NOT NULL)) OR
            ((NEW.currencyCode IS NOT NULL) AND (OLD.currencyCode IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'currencyCode'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.currencySymbol != OLD.currencySymbol) OR
            ((NEW.currencySymbol IS NULL) AND (OLD.currencySymbol IS NOT NULL)) OR
            ((NEW.currencySymbol IS NOT NULL) AND (OLD.currencySymbol IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'currencySymbol'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.exchangeRateToBase != OLD.exchangeRateToBase) OR
            ((NEW.exchangeRateToBase IS NULL) AND (OLD.exchangeRateToBase IS NOT NULL)) OR
            ((NEW.exchangeRateToBase IS NOT NULL) AND (OLD.exchangeRateToBase IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'exchangeRateToBase'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.exchangeRateDate != OLD.exchangeRateDate) OR
            ((NEW.exchangeRateDate IS NULL) AND (OLD.exchangeRateDate IS NOT NULL)) OR
            ((NEW.exchangeRateDate IS NOT NULL) AND (OLD.exchangeRateDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'exchangeRateDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.isBaseCurrency != OLD.isBaseCurrency) OR
            ((NEW.isBaseCurrency IS NULL) AND (OLD.isBaseCurrency IS NOT NULL)) OR
            ((NEW.isBaseCurrency IS NOT NULL) AND (OLD.isBaseCurrency IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'isBaseCurrency'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.active != OLD.active) OR
            ((NEW.active IS NULL) AND (OLD.active IS NOT NULL)) OR
            ((NEW.active IS NOT NULL) AND (OLD.active IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'active'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.localeIdentifier != OLD.localeIdentifier) OR
            ((NEW.localeIdentifier IS NULL) AND (OLD.localeIdentifier IS NOT NULL)) OR
            ((NEW.localeIdentifier IS NOT NULL) AND (OLD.localeIdentifier IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'localeIdentifier'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.overrideLocaleIdentifier != OLD.overrideLocaleIdentifier) OR
            ((NEW.overrideLocaleIdentifier IS NULL) AND (OLD.overrideLocaleIdentifier IS NOT NULL)) OR
            ((NEW.overrideLocaleIdentifier IS NOT NULL) AND (OLD.overrideLocaleIdentifier IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'overrideLocaleIdentifier'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra1 != OLD.extra1) OR
            ((NEW.extra1 IS NULL) AND (OLD.extra1 IS NOT NULL)) OR
            ((NEW.extra1 IS NOT NULL) AND (OLD.extra1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra2 != OLD.extra2) OR
            ((NEW.extra2 IS NULL) AND (OLD.extra2 IS NOT NULL)) OR
            ((NEW.extra2 IS NOT NULL) AND (OLD.extra2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra3 != OLD.extra3) OR
            ((NEW.extra3 IS NULL) AND (OLD.extra3 IS NOT NULL)) OR
            ((NEW.extra3 IS NOT NULL) AND (OLD.extra3 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra3'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra4 != OLD.extra4) OR
            ((NEW.extra4 IS NULL) AND (OLD.extra4 IS NOT NULL)) OR
            ((NEW.extra4 IS NOT NULL) AND (OLD.extra4 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra4'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_currency_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Currency_change_log_trigger ON Currency;
CREATE TRIGGER Currency_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Currency FOR EACH ROW EXECUTE PROCEDURE mc_currency_change_log(35);
CREATE OR REPLACE FUNCTION mc_estimate_change_log() RETURNS TRIGGER AS $mc_estimate_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.billingsFileID != OLD.billingsFileID) OR
            ((NEW.billingsFileID IS NULL) AND (OLD.billingsFileID IS NOT NULL)) OR
            ((NEW.billingsFileID IS NOT NULL) AND (OLD.billingsFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'billingsFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.compoundSecondaryTax != OLD.compoundSecondaryTax) OR
            ((NEW.compoundSecondaryTax IS NULL) AND (OLD.compoundSecondaryTax IS NOT NULL)) OR
            ((NEW.compoundSecondaryTax IS NOT NULL) AND (OLD.compoundSecondaryTax IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'compoundSecondaryTax'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.discount != OLD.discount) OR
            ((NEW.discount IS NULL) AND (OLD.discount IS NOT NULL)) OR
            ((NEW.discount IS NOT NULL) AND (OLD.discount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'discount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.dueDate != OLD.dueDate) OR
            ((NEW.dueDate IS NULL) AND (OLD.dueDate IS NOT NULL)) OR
            ((NEW.dueDate IS NOT NULL) AND (OLD.dueDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'dueDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.estimateNumber != OLD.estimateNumber) OR
            ((NEW.estimateNumber IS NULL) AND (OLD.estimateNumber IS NOT NULL)) OR
            ((NEW.estimateNumber IS NOT NULL) AND (OLD.estimateNumber IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'estimateNumber'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.markup != OLD.markup) OR
            ((NEW.markup IS NULL) AND (OLD.markup IS NOT NULL)) OR
            ((NEW.markup IS NOT NULL) AND (OLD.markup IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'markup'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.sentDate != OLD.sentDate) OR
            ((NEW.sentDate IS NULL) AND (OLD.sentDate IS NOT NULL)) OR
            ((NEW.sentDate IS NOT NULL) AND (OLD.sentDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'sentDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.state != OLD.state) OR
            ((NEW.state IS NULL) AND (OLD.state IS NOT NULL)) OR
            ((NEW.state IS NOT NULL) AND (OLD.state IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'state'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.subTotal != OLD.subTotal) OR
            ((NEW.subTotal IS NULL) AND (OLD.subTotal IS NOT NULL)) OR
            ((NEW.subTotal IS NOT NULL) AND (OLD.subTotal IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'subTotal'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1 != OLD.tax1) OR
            ((NEW.tax1 IS NULL) AND (OLD.tax1 IS NOT NULL)) OR
            ((NEW.tax1 IS NOT NULL) AND (OLD.tax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1Name != OLD.tax1Name) OR
            ((NEW.tax1Name IS NULL) AND (OLD.tax1Name IS NOT NULL)) OR
            ((NEW.tax1Name IS NOT NULL) AND (OLD.tax1Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2 != OLD.tax2) OR
            ((NEW.tax2 IS NULL) AND (OLD.tax2 IS NOT NULL)) OR
            ((NEW.tax2 IS NOT NULL) AND (OLD.tax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2Name != OLD.tax2Name) OR
            ((NEW.tax2Name IS NULL) AND (OLD.tax2Name IS NOT NULL)) OR
            ((NEW.tax2Name IS NOT NULL) AND (OLD.tax2Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax1 != OLD.useTax1) OR
            ((NEW.useTax1 IS NULL) AND (OLD.useTax1 IS NOT NULL)) OR
            ((NEW.useTax1 IS NOT NULL) AND (OLD.useTax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax2 != OLD.useTax2) OR
            ((NEW.useTax2 IS NULL) AND (OLD.useTax2 IS NOT NULL)) OR
            ((NEW.useTax2 IS NOT NULL) AND (OLD.useTax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userFileID != OLD.userFileID) OR
            ((NEW.userFileID IS NULL) AND (OLD.userFileID IS NOT NULL)) OR
            ((NEW.userFileID IS NOT NULL) AND (OLD.userFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.estimateHtmlID != OLD.estimateHtmlID) OR
            ((NEW.estimateHtmlID IS NULL) AND (OLD.estimateHtmlID IS NOT NULL)) OR
            ((NEW.estimateHtmlID IS NOT NULL) AND (OLD.estimateHtmlID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'estimateHtmlID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_estimate_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Estimate_change_log_trigger ON Estimate;
CREATE TRIGGER Estimate_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Estimate FOR EACH ROW EXECUTE PROCEDURE mc_estimate_change_log(8);
CREATE OR REPLACE FUNCTION mc_estimatehtml_change_log() RETURNS TRIGGER AS $mc_estimatehtml_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.html != OLD.html) OR
            ((NEW.html IS NULL) AND (OLD.html IS NOT NULL)) OR
            ((NEW.html IS NOT NULL) AND (OLD.html IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'html'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.type != OLD.type) OR
            ((NEW.type IS NULL) AND (OLD.type IS NOT NULL)) OR
            ((NEW.type IS NOT NULL) AND (OLD.type IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'type'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_estimatehtml_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS EstimateHtml_change_log_trigger ON EstimateHtml;
CREATE TRIGGER EstimateHtml_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON EstimateHtml FOR EACH ROW EXECUTE PROCEDURE mc_estimatehtml_change_log(36);
CREATE OR REPLACE FUNCTION mc_estimateslip_change_log() RETURNS TRIGGER AS $mc_estimateslip_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.categoryID != OLD.categoryID) OR
            ((NEW.categoryID IS NULL) AND (OLD.categoryID IS NOT NULL)) OR
            ((NEW.categoryID IS NOT NULL) AND (OLD.categoryID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'categoryID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userID != OLD.userID) OR
            ((NEW.userID IS NULL) AND (OLD.userID IS NOT NULL)) OR
            ((NEW.userID IS NOT NULL) AND (OLD.userID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.compoundSecondaryTax != OLD.compoundSecondaryTax) OR
            ((NEW.compoundSecondaryTax IS NULL) AND (OLD.compoundSecondaryTax IS NOT NULL)) OR
            ((NEW.compoundSecondaryTax IS NOT NULL) AND (OLD.compoundSecondaryTax IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'compoundSecondaryTax'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.discount != OLD.discount) OR
            ((NEW.discount IS NULL) AND (OLD.discount IS NOT NULL)) OR
            ((NEW.discount IS NOT NULL) AND (OLD.discount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'discount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.distance != OLD.distance) OR
            ((NEW.distance IS NULL) AND (OLD.distance IS NOT NULL)) OR
            ((NEW.distance IS NOT NULL) AND (OLD.distance IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'distance'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.dueDate != OLD.dueDate) OR
            ((NEW.dueDate IS NULL) AND (OLD.dueDate IS NOT NULL)) OR
            ((NEW.dueDate IS NOT NULL) AND (OLD.dueDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'dueDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.duration != OLD.duration) OR
            ((NEW.duration IS NULL) AND (OLD.duration IS NOT NULL)) OR
            ((NEW.duration IS NOT NULL) AND (OLD.duration IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'duration'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.endDateTime != OLD.endDateTime) OR
            ((NEW.endDateTime IS NULL) AND (OLD.endDateTime IS NOT NULL)) OR
            ((NEW.endDateTime IS NOT NULL) AND (OLD.endDateTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'endDateTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.estimateID != OLD.estimateID) OR
            ((NEW.estimateID IS NULL) AND (OLD.estimateID IS NOT NULL)) OR
            ((NEW.estimateID IS NOT NULL) AND (OLD.estimateID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'estimateID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppEntityName != OLD.foreignAppEntityName) OR
            ((NEW.foreignAppEntityName IS NULL) AND (OLD.foreignAppEntityName IS NOT NULL)) OR
            ((NEW.foreignAppEntityName IS NOT NULL) AND (OLD.foreignAppEntityName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppEntityName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppImportID != OLD.foreignAppImportID) OR
            ((NEW.foreignAppImportID IS NULL) AND (OLD.foreignAppImportID IS NOT NULL)) OR
            ((NEW.foreignAppImportID IS NOT NULL) AND (OLD.foreignAppImportID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppImportID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppLastTouchDate != OLD.foreignAppLastTouchDate) OR
            ((NEW.foreignAppLastTouchDate IS NULL) AND (OLD.foreignAppLastTouchDate IS NOT NULL)) OR
            ((NEW.foreignAppLastTouchDate IS NOT NULL) AND (OLD.foreignAppLastTouchDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppLastTouchDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppName != OLD.foreignAppName) OR
            ((NEW.foreignAppName IS NULL) AND (OLD.foreignAppName IS NOT NULL)) OR
            ((NEW.foreignAppName IS NOT NULL) AND (OLD.foreignAppName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppUser != OLD.foreignAppUser) OR
            ((NEW.foreignAppUser IS NULL) AND (OLD.foreignAppUser IS NOT NULL)) OR
            ((NEW.foreignAppUser IS NOT NULL) AND (OLD.foreignAppUser IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppUser'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.markup != OLD.markup) OR
            ((NEW.markup IS NULL) AND (OLD.markup IS NOT NULL)) OR
            ((NEW.markup IS NOT NULL) AND (OLD.markup IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'markup'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.mileageType != OLD.mileageType) OR
            ((NEW.mileageType IS NULL) AND (OLD.mileageType IS NOT NULL)) OR
            ((NEW.mileageType IS NOT NULL) AND (OLD.mileageType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'mileageType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.nature != OLD.nature) OR
            ((NEW.nature IS NULL) AND (OLD.nature IS NOT NULL)) OR
            ((NEW.nature IS NOT NULL) AND (OLD.nature IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'nature'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.rate != OLD.rate) OR
            ((NEW.rate IS NULL) AND (OLD.rate IS NOT NULL)) OR
            ((NEW.rate IS NOT NULL) AND (OLD.rate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'rate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.roundTime != OLD.roundTime) OR
            ((NEW.roundTime IS NULL) AND (OLD.roundTime IS NOT NULL)) OR
            ((NEW.roundTime IS NOT NULL) AND (OLD.roundTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'roundTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.startDateTime != OLD.startDateTime) OR
            ((NEW.startDateTime IS NULL) AND (OLD.startDateTime IS NOT NULL)) OR
            ((NEW.startDateTime IS NOT NULL) AND (OLD.startDateTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'startDateTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1 != OLD.tax1) OR
            ((NEW.tax1 IS NULL) AND (OLD.tax1 IS NOT NULL)) OR
            ((NEW.tax1 IS NOT NULL) AND (OLD.tax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1Name != OLD.tax1Name) OR
            ((NEW.tax1Name IS NULL) AND (OLD.tax1Name IS NOT NULL)) OR
            ((NEW.tax1Name IS NOT NULL) AND (OLD.tax1Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2 != OLD.tax2) OR
            ((NEW.tax2 IS NULL) AND (OLD.tax2 IS NOT NULL)) OR
            ((NEW.tax2 IS NOT NULL) AND (OLD.tax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2Name != OLD.tax2Name) OR
            ((NEW.tax2Name IS NULL) AND (OLD.tax2Name IS NOT NULL)) OR
            ((NEW.tax2Name IS NOT NULL) AND (OLD.tax2Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.timeSlipRefID != OLD.timeSlipRefID) OR
            ((NEW.timeSlipRefID IS NULL) AND (OLD.timeSlipRefID IS NOT NULL)) OR
            ((NEW.timeSlipRefID IS NOT NULL) AND (OLD.timeSlipRefID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'timeSlipRefID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.total != OLD.total) OR
            ((NEW.total IS NULL) AND (OLD.total IS NOT NULL)) OR
            ((NEW.total IS NOT NULL) AND (OLD.total IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'total'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.typeID != OLD.typeID) OR
            ((NEW.typeID IS NULL) AND (OLD.typeID IS NOT NULL)) OR
            ((NEW.typeID IS NOT NULL) AND (OLD.typeID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'typeID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.units != OLD.units) OR
            ((NEW.units IS NULL) AND (OLD.units IS NOT NULL)) OR
            ((NEW.units IS NOT NULL) AND (OLD.units IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'units'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax1 != OLD.useTax1) OR
            ((NEW.useTax1 IS NULL) AND (OLD.useTax1 IS NOT NULL)) OR
            ((NEW.useTax1 IS NOT NULL) AND (OLD.useTax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax2 != OLD.useTax2) OR
            ((NEW.useTax2 IS NULL) AND (OLD.useTax2 IS NOT NULL)) OR
            ((NEW.useTax2 IS NOT NULL) AND (OLD.useTax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.uuid != OLD.uuid) OR
            ((NEW.uuid IS NULL) AND (OLD.uuid IS NOT NULL)) OR
            ((NEW.uuid IS NOT NULL) AND (OLD.uuid IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'uuid'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_estimateslip_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS EstimateSlip_change_log_trigger ON EstimateSlip;
CREATE TRIGGER EstimateSlip_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON EstimateSlip FOR EACH ROW EXECUTE PROCEDURE mc_estimateslip_change_log(9);
CREATE OR REPLACE FUNCTION mc_extra_change_log() RETURNS TRIGGER AS $mc_extra_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.mimeType != OLD.mimeType) OR
            ((NEW.mimeType IS NULL) AND (OLD.mimeType IS NOT NULL)) OR
            ((NEW.mimeType IS NOT NULL) AND (OLD.mimeType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'mimeType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.mimeSubtype != OLD.mimeSubtype) OR
            ((NEW.mimeSubtype IS NULL) AND (OLD.mimeSubtype IS NOT NULL)) OR
            ((NEW.mimeSubtype IS NOT NULL) AND (OLD.mimeSubtype IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'mimeSubtype'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.internalType != OLD.internalType) OR
            ((NEW.internalType IS NULL) AND (OLD.internalType IS NOT NULL)) OR
            ((NEW.internalType IS NOT NULL) AND (OLD.internalType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'internalType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.dataValue != OLD.dataValue) OR
            ((NEW.dataValue IS NULL) AND (OLD.dataValue IS NOT NULL)) OR
            ((NEW.dataValue IS NOT NULL) AND (OLD.dataValue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'dataValue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.stringValue != OLD.stringValue) OR
            ((NEW.stringValue IS NULL) AND (OLD.stringValue IS NOT NULL)) OR
            ((NEW.stringValue IS NOT NULL) AND (OLD.stringValue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'stringValue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.datetimeValue != OLD.datetimeValue) OR
            ((NEW.datetimeValue IS NULL) AND (OLD.datetimeValue IS NOT NULL)) OR
            ((NEW.datetimeValue IS NOT NULL) AND (OLD.datetimeValue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'datetimeValue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.doubleValue != OLD.doubleValue) OR
            ((NEW.doubleValue IS NULL) AND (OLD.doubleValue IS NOT NULL)) OR
            ((NEW.doubleValue IS NOT NULL) AND (OLD.doubleValue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'doubleValue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.floatValue != OLD.floatValue) OR
            ((NEW.floatValue IS NULL) AND (OLD.floatValue IS NOT NULL)) OR
            ((NEW.floatValue IS NOT NULL) AND (OLD.floatValue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'floatValue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.intValue != OLD.intValue) OR
            ((NEW.intValue IS NULL) AND (OLD.intValue IS NOT NULL)) OR
            ((NEW.intValue IS NOT NULL) AND (OLD.intValue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'intValue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.parentEntity != OLD.parentEntity) OR
            ((NEW.parentEntity IS NULL) AND (OLD.parentEntity IS NOT NULL)) OR
            ((NEW.parentEntity IS NOT NULL) AND (OLD.parentEntity IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'parentEntity'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.parentID != OLD.parentID) OR
            ((NEW.parentID IS NULL) AND (OLD.parentID IS NOT NULL)) OR
            ((NEW.parentID IS NOT NULL) AND (OLD.parentID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'parentID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_extra_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Extra_change_log_trigger ON Extra;
CREATE TRIGGER Extra_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Extra FOR EACH ROW EXECUTE PROCEDURE mc_extra_change_log(37);
CREATE OR REPLACE FUNCTION mc_extrafieldnames_change_log() RETURNS TRIGGER AS $mc_extrafieldnames_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.extraField1Name != OLD.extraField1Name) OR
            ((NEW.extraField1Name IS NULL) AND (OLD.extraField1Name IS NOT NULL)) OR
            ((NEW.extraField1Name IS NOT NULL) AND (OLD.extraField1Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField1Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField2Name != OLD.extraField2Name) OR
            ((NEW.extraField2Name IS NULL) AND (OLD.extraField2Name IS NOT NULL)) OR
            ((NEW.extraField2Name IS NOT NULL) AND (OLD.extraField2Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField2Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField3Name != OLD.extraField3Name) OR
            ((NEW.extraField3Name IS NULL) AND (OLD.extraField3Name IS NOT NULL)) OR
            ((NEW.extraField3Name IS NOT NULL) AND (OLD.extraField3Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField3Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField4Name != OLD.extraField4Name) OR
            ((NEW.extraField4Name IS NULL) AND (OLD.extraField4Name IS NOT NULL)) OR
            ((NEW.extraField4Name IS NOT NULL) AND (OLD.extraField4Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField4Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField5Name != OLD.extraField5Name) OR
            ((NEW.extraField5Name IS NULL) AND (OLD.extraField5Name IS NOT NULL)) OR
            ((NEW.extraField5Name IS NOT NULL) AND (OLD.extraField5Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField5Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField6Name != OLD.extraField6Name) OR
            ((NEW.extraField6Name IS NULL) AND (OLD.extraField6Name IS NOT NULL)) OR
            ((NEW.extraField6Name IS NOT NULL) AND (OLD.extraField6Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField6Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField7Name != OLD.extraField7Name) OR
            ((NEW.extraField7Name IS NULL) AND (OLD.extraField7Name IS NOT NULL)) OR
            ((NEW.extraField7Name IS NOT NULL) AND (OLD.extraField7Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField7Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField8Name != OLD.extraField8Name) OR
            ((NEW.extraField8Name IS NULL) AND (OLD.extraField8Name IS NOT NULL)) OR
            ((NEW.extraField8Name IS NOT NULL) AND (OLD.extraField8Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField8Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.forEntity != OLD.forEntity) OR
            ((NEW.forEntity IS NULL) AND (OLD.forEntity IS NOT NULL)) OR
            ((NEW.forEntity IS NOT NULL) AND (OLD.forEntity IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'forEntity'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_extrafieldnames_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ExtraFieldNames_change_log_trigger ON ExtraFieldNames;
CREATE TRIGGER ExtraFieldNames_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ExtraFieldNames FOR EACH ROW EXECUTE PROCEDURE mc_extrafieldnames_change_log(10);
CREATE OR REPLACE FUNCTION mc_identity_change_log() RETURNS TRIGGER AS $mc_identity_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.logo != OLD.logo) OR
            ((NEW.logo IS NULL) AND (OLD.logo IS NOT NULL)) OR
            ((NEW.logo IS NOT NULL) AND (OLD.logo IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'logo'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.logoType != OLD.logoType) OR
            ((NEW.logoType IS NULL) AND (OLD.logoType IS NOT NULL)) OR
            ((NEW.logoType IS NOT NULL) AND (OLD.logoType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'logoType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.line1 != OLD.line1) OR
            ((NEW.line1 IS NULL) AND (OLD.line1 IS NOT NULL)) OR
            ((NEW.line1 IS NOT NULL) AND (OLD.line1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'line1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.line2 != OLD.line2) OR
            ((NEW.line2 IS NULL) AND (OLD.line2 IS NOT NULL)) OR
            ((NEW.line2 IS NOT NULL) AND (OLD.line2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'line2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.line3 != OLD.line3) OR
            ((NEW.line3 IS NULL) AND (OLD.line3 IS NOT NULL)) OR
            ((NEW.line3 IS NOT NULL) AND (OLD.line3 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'line3'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.line4 != OLD.line4) OR
            ((NEW.line4 IS NULL) AND (OLD.line4 IS NOT NULL)) OR
            ((NEW.line4 IS NOT NULL) AND (OLD.line4 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'line4'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.bankAccount != OLD.bankAccount) OR
            ((NEW.bankAccount IS NULL) AND (OLD.bankAccount IS NOT NULL)) OR
            ((NEW.bankAccount IS NOT NULL) AND (OLD.bankAccount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'bankAccount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.bankIdentifier != OLD.bankIdentifier) OR
            ((NEW.bankIdentifier IS NULL) AND (OLD.bankIdentifier IS NOT NULL)) OR
            ((NEW.bankIdentifier IS NOT NULL) AND (OLD.bankIdentifier IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'bankIdentifier'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.bankName != OLD.bankName) OR
            ((NEW.bankName IS NULL) AND (OLD.bankName IS NOT NULL)) OR
            ((NEW.bankName IS NOT NULL) AND (OLD.bankName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'bankName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.bankAddress != OLD.bankAddress) OR
            ((NEW.bankAddress IS NULL) AND (OLD.bankAddress IS NOT NULL)) OR
            ((NEW.bankAddress IS NOT NULL) AND (OLD.bankAddress IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'bankAddress'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.IBAN != OLD.IBAN) OR
            ((NEW.IBAN IS NULL) AND (OLD.IBAN IS NOT NULL)) OR
            ((NEW.IBAN IS NOT NULL) AND (OLD.IBAN IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'IBAN'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.BIC != OLD.BIC) OR
            ((NEW.BIC IS NULL) AND (OLD.BIC IS NOT NULL)) OR
            ((NEW.BIC IS NOT NULL) AND (OLD.BIC IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'BIC'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra1 != OLD.extra1) OR
            ((NEW.extra1 IS NULL) AND (OLD.extra1 IS NOT NULL)) OR
            ((NEW.extra1 IS NOT NULL) AND (OLD.extra1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra2 != OLD.extra2) OR
            ((NEW.extra2 IS NULL) AND (OLD.extra2 IS NOT NULL)) OR
            ((NEW.extra2 IS NOT NULL) AND (OLD.extra2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra3 != OLD.extra3) OR
            ((NEW.extra3 IS NULL) AND (OLD.extra3 IS NOT NULL)) OR
            ((NEW.extra3 IS NOT NULL) AND (OLD.extra3 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra3'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra4 != OLD.extra4) OR
            ((NEW.extra4 IS NULL) AND (OLD.extra4 IS NOT NULL)) OR
            ((NEW.extra4 IS NOT NULL) AND (OLD.extra4 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra4'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_identity_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Identity_change_log_trigger ON Identity;
CREATE TRIGGER Identity_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Identity FOR EACH ROW EXECUTE PROCEDURE mc_identity_change_log(45);
CREATE OR REPLACE FUNCTION mc_invoice_change_log() RETURNS TRIGGER AS $mc_invoice_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.billingsFileID != OLD.billingsFileID) OR
            ((NEW.billingsFileID IS NULL) AND (OLD.billingsFileID IS NOT NULL)) OR
            ((NEW.billingsFileID IS NOT NULL) AND (OLD.billingsFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'billingsFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.compoundSecondaryTax != OLD.compoundSecondaryTax) OR
            ((NEW.compoundSecondaryTax IS NULL) AND (OLD.compoundSecondaryTax IS NOT NULL)) OR
            ((NEW.compoundSecondaryTax IS NOT NULL) AND (OLD.compoundSecondaryTax IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'compoundSecondaryTax'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.discount != OLD.discount) OR
            ((NEW.discount IS NULL) AND (OLD.discount IS NOT NULL)) OR
            ((NEW.discount IS NOT NULL) AND (OLD.discount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'discount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.dueDate != OLD.dueDate) OR
            ((NEW.dueDate IS NULL) AND (OLD.dueDate IS NOT NULL)) OR
            ((NEW.dueDate IS NOT NULL) AND (OLD.dueDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'dueDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoiceDate != OLD.invoiceDate) OR
            ((NEW.invoiceDate IS NULL) AND (OLD.invoiceDate IS NOT NULL)) OR
            ((NEW.invoiceDate IS NOT NULL) AND (OLD.invoiceDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoiceDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoiceNumber != OLD.invoiceNumber) OR
            ((NEW.invoiceNumber IS NULL) AND (OLD.invoiceNumber IS NOT NULL)) OR
            ((NEW.invoiceNumber IS NOT NULL) AND (OLD.invoiceNumber IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoiceNumber'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.markup != OLD.markup) OR
            ((NEW.markup IS NULL) AND (OLD.markup IS NOT NULL)) OR
            ((NEW.markup IS NOT NULL) AND (OLD.markup IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'markup'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.sentDate != OLD.sentDate) OR
            ((NEW.sentDate IS NULL) AND (OLD.sentDate IS NOT NULL)) OR
            ((NEW.sentDate IS NOT NULL) AND (OLD.sentDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'sentDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.state != OLD.state) OR
            ((NEW.state IS NULL) AND (OLD.state IS NOT NULL)) OR
            ((NEW.state IS NOT NULL) AND (OLD.state IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'state'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1 != OLD.tax1) OR
            ((NEW.tax1 IS NULL) AND (OLD.tax1 IS NOT NULL)) OR
            ((NEW.tax1 IS NOT NULL) AND (OLD.tax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1Name != OLD.tax1Name) OR
            ((NEW.tax1Name IS NULL) AND (OLD.tax1Name IS NOT NULL)) OR
            ((NEW.tax1Name IS NOT NULL) AND (OLD.tax1Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2 != OLD.tax2) OR
            ((NEW.tax2 IS NULL) AND (OLD.tax2 IS NOT NULL)) OR
            ((NEW.tax2 IS NOT NULL) AND (OLD.tax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2Name != OLD.tax2Name) OR
            ((NEW.tax2Name IS NULL) AND (OLD.tax2Name IS NOT NULL)) OR
            ((NEW.tax2Name IS NOT NULL) AND (OLD.tax2Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.taxPointDate != OLD.taxPointDate) OR
            ((NEW.taxPointDate IS NULL) AND (OLD.taxPointDate IS NOT NULL)) OR
            ((NEW.taxPointDate IS NOT NULL) AND (OLD.taxPointDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'taxPointDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax1 != OLD.useTax1) OR
            ((NEW.useTax1 IS NULL) AND (OLD.useTax1 IS NOT NULL)) OR
            ((NEW.useTax1 IS NOT NULL) AND (OLD.useTax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax2 != OLD.useTax2) OR
            ((NEW.useTax2 IS NULL) AND (OLD.useTax2 IS NOT NULL)) OR
            ((NEW.useTax2 IS NOT NULL) AND (OLD.useTax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userFileID != OLD.userFileID) OR
            ((NEW.userFileID IS NULL) AND (OLD.userFileID IS NOT NULL)) OR
            ((NEW.userFileID IS NOT NULL) AND (OLD.userFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoiceHtmlID != OLD.invoiceHtmlID) OR
            ((NEW.invoiceHtmlID IS NULL) AND (OLD.invoiceHtmlID IS NOT NULL)) OR
            ((NEW.invoiceHtmlID IS NOT NULL) AND (OLD.invoiceHtmlID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoiceHtmlID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.totalCached != OLD.totalCached) OR
            ((NEW.totalCached IS NULL) AND (OLD.totalCached IS NOT NULL)) OR
            ((NEW.totalCached IS NOT NULL) AND (OLD.totalCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'totalCached'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_invoice_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Invoice_change_log_trigger ON Invoice;
CREATE TRIGGER Invoice_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Invoice FOR EACH ROW EXECUTE PROCEDURE mc_invoice_change_log(11);
CREATE OR REPLACE FUNCTION mc_invoicehtml_change_log() RETURNS TRIGGER AS $mc_invoicehtml_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.html != OLD.html) OR
            ((NEW.html IS NULL) AND (OLD.html IS NOT NULL)) OR
            ((NEW.html IS NOT NULL) AND (OLD.html IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'html'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.type != OLD.type) OR
            ((NEW.type IS NULL) AND (OLD.type IS NOT NULL)) OR
            ((NEW.type IS NOT NULL) AND (OLD.type IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'type'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_invoicehtml_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS InvoiceHtml_change_log_trigger ON InvoiceHtml;
CREATE TRIGGER InvoiceHtml_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON InvoiceHtml FOR EACH ROW EXECUTE PROCEDURE mc_invoicehtml_change_log(34);
CREATE OR REPLACE FUNCTION mc_mcuserdefaultsstorage_change_log() RETURNS TRIGGER AS $mc_mcuserdefaultsstorage_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.BlobValue != OLD.BlobValue) OR
            ((NEW.BlobValue IS NULL) AND (OLD.BlobValue IS NOT NULL)) OR
            ((NEW.BlobValue IS NOT NULL) AND (OLD.BlobValue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'BlobValue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.HostID != OLD.HostID) OR
            ((NEW.HostID IS NULL) AND (OLD.HostID IS NOT NULL)) OR
            ((NEW.HostID IS NOT NULL) AND (OLD.HostID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'HostID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.Key != OLD.Key) OR
            ((NEW.Key IS NULL) AND (OLD.Key IS NOT NULL)) OR
            ((NEW.Key IS NOT NULL) AND (OLD.Key IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'Key'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.LastType != OLD.LastType) OR
            ((NEW.LastType IS NULL) AND (OLD.LastType IS NOT NULL)) OR
            ((NEW.LastType IS NOT NULL) AND (OLD.LastType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'LastType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.Value != OLD.Value) OR
            ((NEW.Value IS NULL) AND (OLD.Value IS NOT NULL)) OR
            ((NEW.Value IS NOT NULL) AND (OLD.Value IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'Value'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_mcuserdefaultsstorage_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS MCUserDefaultsStorage_change_log_trigger ON MCUserDefaultsStorage;
CREATE TRIGGER MCUserDefaultsStorage_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON MCUserDefaultsStorage FOR EACH ROW EXECUTE PROCEDURE mc_mcuserdefaultsstorage_change_log(12);
CREATE OR REPLACE FUNCTION mc_note_change_log() RETURNS TRIGGER AS $mc_note_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.contents != OLD.contents) OR
            ((NEW.contents IS NULL) AND (OLD.contents IS NOT NULL)) OR
            ((NEW.contents IS NOT NULL) AND (OLD.contents IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'contents'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.plainContents != OLD.plainContents) OR
            ((NEW.plainContents IS NULL) AND (OLD.plainContents IS NOT NULL)) OR
            ((NEW.plainContents IS NOT NULL) AND (OLD.plainContents IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'plainContents'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_note_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Note_change_log_trigger ON Note;
CREATE TRIGGER Note_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Note FOR EACH ROW EXECUTE PROCEDURE mc_note_change_log(13);
CREATE OR REPLACE FUNCTION mc_payment_change_log() RETURNS TRIGGER AS $mc_payment_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.cachedAppliedAmount != OLD.cachedAppliedAmount) OR
            ((NEW.cachedAppliedAmount IS NULL) AND (OLD.cachedAppliedAmount IS NOT NULL)) OR
            ((NEW.cachedAppliedAmount IS NOT NULL) AND (OLD.cachedAppliedAmount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'cachedAppliedAmount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.methodID != OLD.methodID) OR
            ((NEW.methodID IS NULL) AND (OLD.methodID IS NOT NULL)) OR
            ((NEW.methodID IS NOT NULL) AND (OLD.methodID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'methodID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.total != OLD.total) OR
            ((NEW.total IS NULL) AND (OLD.total IS NOT NULL)) OR
            ((NEW.total IS NOT NULL) AND (OLD.total IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'total'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.baseCurrencyTotal != OLD.baseCurrencyTotal) OR
            ((NEW.baseCurrencyTotal IS NULL) AND (OLD.baseCurrencyTotal IS NOT NULL)) OR
            ((NEW.baseCurrencyTotal IS NOT NULL) AND (OLD.baseCurrencyTotal IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'baseCurrencyTotal'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.baseCurrencyManuallyEntered != OLD.baseCurrencyManuallyEntered) OR
            ((NEW.baseCurrencyManuallyEntered IS NULL) AND (OLD.baseCurrencyManuallyEntered IS NOT NULL)) OR
            ((NEW.baseCurrencyManuallyEntered IS NOT NULL) AND (OLD.baseCurrencyManuallyEntered IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'baseCurrencyManuallyEntered'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_payment_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Payment_change_log_trigger ON Payment;
CREATE TRIGGER Payment_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Payment FOR EACH ROW EXECUTE PROCEDURE mc_payment_change_log(14);
CREATE OR REPLACE FUNCTION mc_paymentinvoiceentry_change_log() RETURNS TRIGGER AS $mc_paymentinvoiceentry_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.amountApplied != OLD.amountApplied) OR
            ((NEW.amountApplied IS NULL) AND (OLD.amountApplied IS NOT NULL)) OR
            ((NEW.amountApplied IS NOT NULL) AND (OLD.amountApplied IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'amountApplied'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoiceID != OLD.invoiceID) OR
            ((NEW.invoiceID IS NULL) AND (OLD.invoiceID IS NOT NULL)) OR
            ((NEW.invoiceID IS NOT NULL) AND (OLD.invoiceID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoiceID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.paymentID != OLD.paymentID) OR
            ((NEW.paymentID IS NULL) AND (OLD.paymentID IS NOT NULL)) OR
            ((NEW.paymentID IS NOT NULL) AND (OLD.paymentID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'paymentID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_paymentinvoiceentry_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS PaymentInvoiceEntry_change_log_trigger ON PaymentInvoiceEntry;
CREATE TRIGGER PaymentInvoiceEntry_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON PaymentInvoiceEntry FOR EACH ROW EXECUTE PROCEDURE mc_paymentinvoiceentry_change_log(15);
CREATE OR REPLACE FUNCTION mc_paymentmethodtype_change_log() RETURNS TRIGGER AS $mc_paymentmethodtype_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useRetainer != OLD.useRetainer) OR
            ((NEW.useRetainer IS NULL) AND (OLD.useRetainer IS NOT NULL)) OR
            ((NEW.useRetainer IS NOT NULL) AND (OLD.useRetainer IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useRetainer'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_paymentmethodtype_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS PaymentMethodType_change_log_trigger ON PaymentMethodType;
CREATE TRIGGER PaymentMethodType_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON PaymentMethodType FOR EACH ROW EXECUTE PROCEDURE mc_paymentmethodtype_change_log(16);
CREATE OR REPLACE FUNCTION mc_proformainvoice_change_log() RETURNS TRIGGER AS $mc_proformainvoice_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.billingsFileID != OLD.billingsFileID) OR
            ((NEW.billingsFileID IS NULL) AND (OLD.billingsFileID IS NOT NULL)) OR
            ((NEW.billingsFileID IS NOT NULL) AND (OLD.billingsFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'billingsFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.dueDate != OLD.dueDate) OR
            ((NEW.dueDate IS NULL) AND (OLD.dueDate IS NOT NULL)) OR
            ((NEW.dueDate IS NOT NULL) AND (OLD.dueDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'dueDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoiceDate != OLD.invoiceDate) OR
            ((NEW.invoiceDate IS NULL) AND (OLD.invoiceDate IS NOT NULL)) OR
            ((NEW.invoiceDate IS NOT NULL) AND (OLD.invoiceDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoiceDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userFileID != OLD.userFileID) OR
            ((NEW.userFileID IS NULL) AND (OLD.userFileID IS NOT NULL)) OR
            ((NEW.userFileID IS NOT NULL) AND (OLD.userFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.slipList != OLD.slipList) OR
            ((NEW.slipList IS NULL) AND (OLD.slipList IS NOT NULL)) OR
            ((NEW.slipList IS NOT NULL) AND (OLD.slipList IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'slipList'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.templatePath != OLD.templatePath) OR
            ((NEW.templatePath IS NULL) AND (OLD.templatePath IS NOT NULL)) OR
            ((NEW.templatePath IS NOT NULL) AND (OLD.templatePath IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'templatePath'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.total != OLD.total) OR
            ((NEW.total IS NULL) AND (OLD.total IS NOT NULL)) OR
            ((NEW.total IS NOT NULL) AND (OLD.total IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'total'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.retainerAmountApplied != OLD.retainerAmountApplied) OR
            ((NEW.retainerAmountApplied IS NULL) AND (OLD.retainerAmountApplied IS NOT NULL)) OR
            ((NEW.retainerAmountApplied IS NOT NULL) AND (OLD.retainerAmountApplied IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'retainerAmountApplied'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.customizationValues != OLD.customizationValues) OR
            ((NEW.customizationValues IS NULL) AND (OLD.customizationValues IS NOT NULL)) OR
            ((NEW.customizationValues IS NOT NULL) AND (OLD.customizationValues IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'customizationValues'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.templatePreferenceID != OLD.templatePreferenceID) OR
            ((NEW.templatePreferenceID IS NULL) AND (OLD.templatePreferenceID IS NOT NULL)) OR
            ((NEW.templatePreferenceID IS NOT NULL) AND (OLD.templatePreferenceID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'templatePreferenceID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_proformainvoice_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ProFormaInvoice_change_log_trigger ON ProFormaInvoice;
CREATE TRIGGER ProFormaInvoice_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ProFormaInvoice FOR EACH ROW EXECUTE PROCEDURE mc_proformainvoice_change_log(17);
CREATE OR REPLACE FUNCTION mc_project_change_log() RETURNS TRIGGER AS $mc_project_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.balance != OLD.balance) OR
            ((NEW.balance IS NULL) AND (OLD.balance IS NOT NULL)) OR
            ((NEW.balance IS NOT NULL) AND (OLD.balance IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'balance'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.completeDate != OLD.completeDate) OR
            ((NEW.completeDate IS NULL) AND (OLD.completeDate IS NOT NULL)) OR
            ((NEW.completeDate IS NOT NULL) AND (OLD.completeDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'completeDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.discount != OLD.discount) OR
            ((NEW.discount IS NULL) AND (OLD.discount IS NOT NULL)) OR
            ((NEW.discount IS NOT NULL) AND (OLD.discount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'discount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.dueDate != OLD.dueDate) OR
            ((NEW.dueDate IS NULL) AND (OLD.dueDate IS NOT NULL)) OR
            ((NEW.dueDate IS NOT NULL) AND (OLD.dueDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'dueDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField1 != OLD.extraField1) OR
            ((NEW.extraField1 IS NULL) AND (OLD.extraField1 IS NOT NULL)) OR
            ((NEW.extraField1 IS NOT NULL) AND (OLD.extraField1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField2 != OLD.extraField2) OR
            ((NEW.extraField2 IS NULL) AND (OLD.extraField2 IS NOT NULL)) OR
            ((NEW.extraField2 IS NOT NULL) AND (OLD.extraField2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField3 != OLD.extraField3) OR
            ((NEW.extraField3 IS NULL) AND (OLD.extraField3 IS NOT NULL)) OR
            ((NEW.extraField3 IS NOT NULL) AND (OLD.extraField3 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField3'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField4 != OLD.extraField4) OR
            ((NEW.extraField4 IS NULL) AND (OLD.extraField4 IS NOT NULL)) OR
            ((NEW.extraField4 IS NOT NULL) AND (OLD.extraField4 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField4'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField5 != OLD.extraField5) OR
            ((NEW.extraField5 IS NULL) AND (OLD.extraField5 IS NOT NULL)) OR
            ((NEW.extraField5 IS NOT NULL) AND (OLD.extraField5 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField5'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField6 != OLD.extraField6) OR
            ((NEW.extraField6 IS NULL) AND (OLD.extraField6 IS NOT NULL)) OR
            ((NEW.extraField6 IS NOT NULL) AND (OLD.extraField6 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField6'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField7 != OLD.extraField7) OR
            ((NEW.extraField7 IS NULL) AND (OLD.extraField7 IS NOT NULL)) OR
            ((NEW.extraField7 IS NOT NULL) AND (OLD.extraField7 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField7'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extraField8 != OLD.extraField8) OR
            ((NEW.extraField8 IS NULL) AND (OLD.extraField8 IS NOT NULL)) OR
            ((NEW.extraField8 IS NOT NULL) AND (OLD.extraField8 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extraField8'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppEntityName != OLD.foreignAppEntityName) OR
            ((NEW.foreignAppEntityName IS NULL) AND (OLD.foreignAppEntityName IS NOT NULL)) OR
            ((NEW.foreignAppEntityName IS NOT NULL) AND (OLD.foreignAppEntityName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppEntityName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppImportID != OLD.foreignAppImportID) OR
            ((NEW.foreignAppImportID IS NULL) AND (OLD.foreignAppImportID IS NOT NULL)) OR
            ((NEW.foreignAppImportID IS NOT NULL) AND (OLD.foreignAppImportID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppImportID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppLastTouchDate != OLD.foreignAppLastTouchDate) OR
            ((NEW.foreignAppLastTouchDate IS NULL) AND (OLD.foreignAppLastTouchDate IS NOT NULL)) OR
            ((NEW.foreignAppLastTouchDate IS NOT NULL) AND (OLD.foreignAppLastTouchDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppLastTouchDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppName != OLD.foreignAppName) OR
            ((NEW.foreignAppName IS NULL) AND (OLD.foreignAppName IS NOT NULL)) OR
            ((NEW.foreignAppName IS NOT NULL) AND (OLD.foreignAppName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppUser != OLD.foreignAppUser) OR
            ((NEW.foreignAppUser IS NULL) AND (OLD.foreignAppUser IS NOT NULL)) OR
            ((NEW.foreignAppUser IS NOT NULL) AND (OLD.foreignAppUser IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppUser'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.nickname != OLD.nickname) OR
            ((NEW.nickname IS NULL) AND (OLD.nickname IS NOT NULL)) OR
            ((NEW.nickname IS NOT NULL) AND (OLD.nickname IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'nickname'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.objective != OLD.objective) OR
            ((NEW.objective IS NULL) AND (OLD.objective IS NOT NULL)) OR
            ((NEW.objective IS NOT NULL) AND (OLD.objective IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'objective'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.poNumber != OLD.poNumber) OR
            ((NEW.poNumber IS NULL) AND (OLD.poNumber IS NOT NULL)) OR
            ((NEW.poNumber IS NOT NULL) AND (OLD.poNumber IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'poNumber'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectCode != OLD.projectCode) OR
            ((NEW.projectCode IS NULL) AND (OLD.projectCode IS NOT NULL)) OR
            ((NEW.projectCode IS NOT NULL) AND (OLD.projectCode IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectCode'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.stageID != OLD.stageID) OR
            ((NEW.stageID IS NULL) AND (OLD.stageID IS NOT NULL)) OR
            ((NEW.stageID IS NOT NULL) AND (OLD.stageID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'stageID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.startDate != OLD.startDate) OR
            ((NEW.startDate IS NULL) AND (OLD.startDate IS NOT NULL)) OR
            ((NEW.startDate IS NOT NULL) AND (OLD.startDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'startDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.stateID != OLD.stateID) OR
            ((NEW.stateID IS NULL) AND (OLD.stateID IS NOT NULL)) OR
            ((NEW.stateID IS NOT NULL) AND (OLD.stateID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'stateID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.total != OLD.total) OR
            ((NEW.total IS NULL) AND (OLD.total IS NOT NULL)) OR
            ((NEW.total IS NOT NULL) AND (OLD.total IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'total'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useNickname != OLD.useNickname) OR
            ((NEW.useNickname IS NULL) AND (OLD.useNickname IS NOT NULL)) OR
            ((NEW.useNickname IS NOT NULL) AND (OLD.useNickname IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useNickname'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.uuid != OLD.uuid) OR
            ((NEW.uuid IS NULL) AND (OLD.uuid IS NOT NULL)) OR
            ((NEW.uuid IS NOT NULL) AND (OLD.uuid IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'uuid'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.totalCached != OLD.totalCached) OR
            ((NEW.totalCached IS NULL) AND (OLD.totalCached IS NOT NULL)) OR
            ((NEW.totalCached IS NOT NULL) AND (OLD.totalCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'totalCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.unbilledCached != OLD.unbilledCached) OR
            ((NEW.unbilledCached IS NULL) AND (OLD.unbilledCached IS NOT NULL)) OR
            ((NEW.unbilledCached IS NOT NULL) AND (OLD.unbilledCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'unbilledCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.incompleteCached != OLD.incompleteCached) OR
            ((NEW.incompleteCached IS NULL) AND (OLD.incompleteCached IS NOT NULL)) OR
            ((NEW.incompleteCached IS NOT NULL) AND (OLD.incompleteCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'incompleteCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.estimatePendingCached != OLD.estimatePendingCached) OR
            ((NEW.estimatePendingCached IS NULL) AND (OLD.estimatePendingCached IS NOT NULL)) OR
            ((NEW.estimatePendingCached IS NOT NULL) AND (OLD.estimatePendingCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'estimatePendingCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.durationOfSlipsCached != OLD.durationOfSlipsCached) OR
            ((NEW.durationOfSlipsCached IS NULL) AND (OLD.durationOfSlipsCached IS NOT NULL)) OR
            ((NEW.durationOfSlipsCached IS NOT NULL) AND (OLD.durationOfSlipsCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'durationOfSlipsCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.approverID != OLD.approverID) OR
            ((NEW.approverID IS NULL) AND (OLD.approverID IS NOT NULL)) OR
            ((NEW.approverID IS NOT NULL) AND (OLD.approverID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'approverID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_project_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Project_change_log_trigger ON Project;
CREATE TRIGGER Project_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Project FOR EACH ROW EXECUTE PROCEDURE mc_project_change_log(18);
CREATE OR REPLACE FUNCTION mc_projectstage_change_log() RETURNS TRIGGER AS $mc_projectstage_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_projectstage_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ProjectStage_change_log_trigger ON ProjectStage;
CREATE TRIGGER ProjectStage_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ProjectStage FOR EACH ROW EXECUTE PROCEDURE mc_projectstage_change_log(19);
CREATE OR REPLACE FUNCTION mc_projectstate_change_log() RETURNS TRIGGER AS $mc_projectstate_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.stateCode != OLD.stateCode) OR
            ((NEW.stateCode IS NULL) AND (OLD.stateCode IS NOT NULL)) OR
            ((NEW.stateCode IS NOT NULL) AND (OLD.stateCode IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'stateCode'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_projectstate_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ProjectState_change_log_trigger ON ProjectState;
CREATE TRIGGER ProjectState_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ProjectState FOR EACH ROW EXECUTE PROCEDURE mc_projectstate_change_log(20);
CREATE OR REPLACE FUNCTION mc_projectuser_change_log() RETURNS TRIGGER AS $mc_projectuser_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.userID != OLD.userID) OR
            ((NEW.userID IS NULL) AND (OLD.userID IS NOT NULL)) OR
            ((NEW.userID IS NOT NULL) AND (OLD.userID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.hourlyRate != OLD.hourlyRate) OR
            ((NEW.hourlyRate IS NULL) AND (OLD.hourlyRate IS NOT NULL)) OR
            ((NEW.hourlyRate IS NOT NULL) AND (OLD.hourlyRate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'hourlyRate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.mileageRate != OLD.mileageRate) OR
            ((NEW.mileageRate IS NULL) AND (OLD.mileageRate IS NOT NULL)) OR
            ((NEW.mileageRate IS NOT NULL) AND (OLD.mileageRate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'mileageRate'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_projectuser_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ProjectUser_change_log_trigger ON ProjectUser;
CREATE TRIGGER ProjectUser_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ProjectUser FOR EACH ROW EXECUTE PROCEDURE mc_projectuser_change_log(41);
CREATE OR REPLACE FUNCTION mc_recurringinvoice_change_log() RETURNS TRIGGER AS $mc_recurringinvoice_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.lastSentDate != OLD.lastSentDate) OR
            ((NEW.lastSentDate IS NULL) AND (OLD.lastSentDate IS NOT NULL)) OR
            ((NEW.lastSentDate IS NOT NULL) AND (OLD.lastSentDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'lastSentDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.nextSendDate != OLD.nextSendDate) OR
            ((NEW.nextSendDate IS NULL) AND (OLD.nextSendDate IS NOT NULL)) OR
            ((NEW.nextSendDate IS NOT NULL) AND (OLD.nextSendDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'nextSendDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.recurMonths != OLD.recurMonths) OR
            ((NEW.recurMonths IS NULL) AND (OLD.recurMonths IS NOT NULL)) OR
            ((NEW.recurMonths IS NOT NULL) AND (OLD.recurMonths IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'recurMonths'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.recurDay != OLD.recurDay) OR
            ((NEW.recurDay IS NULL) AND (OLD.recurDay IS NOT NULL)) OR
            ((NEW.recurDay IS NOT NULL) AND (OLD.recurDay IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'recurDay'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.templatePath != OLD.templatePath) OR
            ((NEW.templatePath IS NULL) AND (OLD.templatePath IS NOT NULL)) OR
            ((NEW.templatePath IS NOT NULL) AND (OLD.templatePath IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'templatePath'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.lastPlannedSendDate != OLD.lastPlannedSendDate) OR
            ((NEW.lastPlannedSendDate IS NULL) AND (OLD.lastPlannedSendDate IS NOT NULL)) OR
            ((NEW.lastPlannedSendDate IS NOT NULL) AND (OLD.lastPlannedSendDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'lastPlannedSendDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.includeUnbilled != OLD.includeUnbilled) OR
            ((NEW.includeUnbilled IS NULL) AND (OLD.includeUnbilled IS NOT NULL)) OR
            ((NEW.includeUnbilled IS NOT NULL) AND (OLD.includeUnbilled IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'includeUnbilled'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_recurringinvoice_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS RecurringInvoice_change_log_trigger ON RecurringInvoice;
CREATE TRIGGER RecurringInvoice_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON RecurringInvoice FOR EACH ROW EXECUTE PROCEDURE mc_recurringinvoice_change_log(21);
CREATE OR REPLACE FUNCTION mc_reporttemplate_change_log() RETURNS TRIGGER AS $mc_reporttemplate_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.templateData != OLD.templateData) OR
            ((NEW.templateData IS NULL) AND (OLD.templateData IS NOT NULL)) OR
            ((NEW.templateData IS NOT NULL) AND (OLD.templateData IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'templateData'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.behaviors != OLD.behaviors) OR
            ((NEW.behaviors IS NULL) AND (OLD.behaviors IS NOT NULL)) OR
            ((NEW.behaviors IS NOT NULL) AND (OLD.behaviors IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'behaviors'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.entityName != OLD.entityName) OR
            ((NEW.entityName IS NULL) AND (OLD.entityName IS NOT NULL)) OR
            ((NEW.entityName IS NOT NULL) AND (OLD.entityName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'entityName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.isActiveCode != OLD.isActiveCode) OR
            ((NEW.isActiveCode IS NULL) AND (OLD.isActiveCode IS NOT NULL)) OR
            ((NEW.isActiveCode IS NOT NULL) AND (OLD.isActiveCode IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'isActiveCode'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.version != OLD.version) OR
            ((NEW.version IS NULL) AND (OLD.version IS NOT NULL)) OR
            ((NEW.version IS NOT NULL) AND (OLD.version IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'version'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.thumbnailData != OLD.thumbnailData) OR
            ((NEW.thumbnailData IS NULL) AND (OLD.thumbnailData IS NOT NULL)) OR
            ((NEW.thumbnailData IS NOT NULL) AND (OLD.thumbnailData IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'thumbnailData'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.thumbnailType != OLD.thumbnailType) OR
            ((NEW.thumbnailType IS NULL) AND (OLD.thumbnailType IS NOT NULL)) OR
            ((NEW.thumbnailType IS NOT NULL) AND (OLD.thumbnailType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'thumbnailType'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_reporttemplate_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ReportTemplate_change_log_trigger ON ReportTemplate;
CREATE TRIGGER ReportTemplate_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ReportTemplate FOR EACH ROW EXECUTE PROCEDURE mc_reporttemplate_change_log(40);
CREATE OR REPLACE FUNCTION mc_reporttemplatepreference_change_log() RETURNS TRIGGER AS $mc_reporttemplatepreference_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.templateName != OLD.templateName) OR
            ((NEW.templateName IS NULL) AND (OLD.templateName IS NOT NULL)) OR
            ((NEW.templateName IS NOT NULL) AND (OLD.templateName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'templateName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.reportTemplateID != OLD.reportTemplateID) OR
            ((NEW.reportTemplateID IS NULL) AND (OLD.reportTemplateID IS NOT NULL)) OR
            ((NEW.reportTemplateID IS NOT NULL) AND (OLD.reportTemplateID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'reportTemplateID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.configuration != OLD.configuration) OR
            ((NEW.configuration IS NULL) AND (OLD.configuration IS NOT NULL)) OR
            ((NEW.configuration IS NOT NULL) AND (OLD.configuration IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'configuration'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_reporttemplatepreference_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS ReportTemplatePreference_change_log_trigger ON ReportTemplatePreference;
CREATE TRIGGER ReportTemplatePreference_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON ReportTemplatePreference FOR EACH ROW EXECUTE PROCEDURE mc_reporttemplatepreference_change_log(44);
CREATE OR REPLACE FUNCTION mc_retainer_change_log() RETURNS TRIGGER AS $mc_retainer_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.amountApplied != OLD.amountApplied) OR
            ((NEW.amountApplied IS NULL) AND (OLD.amountApplied IS NOT NULL)) OR
            ((NEW.amountApplied IS NOT NULL) AND (OLD.amountApplied IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'amountApplied'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.total != OLD.total) OR
            ((NEW.total IS NULL) AND (OLD.total IS NOT NULL)) OR
            ((NEW.total IS NOT NULL) AND (OLD.total IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'total'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.methodID != OLD.methodID) OR
            ((NEW.methodID IS NULL) AND (OLD.methodID IS NOT NULL)) OR
            ((NEW.methodID IS NOT NULL) AND (OLD.methodID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'methodID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.baseCurrencyTotal != OLD.baseCurrencyTotal) OR
            ((NEW.baseCurrencyTotal IS NULL) AND (OLD.baseCurrencyTotal IS NOT NULL)) OR
            ((NEW.baseCurrencyTotal IS NOT NULL) AND (OLD.baseCurrencyTotal IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'baseCurrencyTotal'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.baseCurrencyManuallyEntered != OLD.baseCurrencyManuallyEntered) OR
            ((NEW.baseCurrencyManuallyEntered IS NULL) AND (OLD.baseCurrencyManuallyEntered IS NOT NULL)) OR
            ((NEW.baseCurrencyManuallyEntered IS NOT NULL) AND (OLD.baseCurrencyManuallyEntered IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'baseCurrencyManuallyEntered'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_retainer_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Retainer_change_log_trigger ON Retainer;
CREATE TRIGGER Retainer_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Retainer FOR EACH ROW EXECUTE PROCEDURE mc_retainer_change_log(22);
CREATE OR REPLACE FUNCTION mc_slipconflict_change_log() RETURNS TRIGGER AS $mc_slipconflict_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.originalSlipID != OLD.originalSlipID) OR
            ((NEW.originalSlipID IS NULL) AND (OLD.originalSlipID IS NOT NULL)) OR
            ((NEW.originalSlipID IS NOT NULL) AND (OLD.originalSlipID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'originalSlipID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.duplicateSlipID != OLD.duplicateSlipID) OR
            ((NEW.duplicateSlipID IS NULL) AND (OLD.duplicateSlipID IS NOT NULL)) OR
            ((NEW.duplicateSlipID IS NOT NULL) AND (OLD.duplicateSlipID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'duplicateSlipID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_slipconflict_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS SlipConflict_change_log_trigger ON SlipConflict;
CREATE TRIGGER SlipConflict_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON SlipConflict FOR EACH ROW EXECUTE PROCEDURE mc_slipconflict_change_log(23);
CREATE OR REPLACE FUNCTION mc_sliptemplate_change_log() RETURNS TRIGGER AS $mc_sliptemplate_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.categoryID != OLD.categoryID) OR
            ((NEW.categoryID IS NULL) AND (OLD.categoryID IS NOT NULL)) OR
            ((NEW.categoryID IS NOT NULL) AND (OLD.categoryID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'categoryID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userID != OLD.userID) OR
            ((NEW.userID IS NULL) AND (OLD.userID IS NOT NULL)) OR
            ((NEW.userID IS NOT NULL) AND (OLD.userID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.discount != OLD.discount) OR
            ((NEW.discount IS NULL) AND (OLD.discount IS NOT NULL)) OR
            ((NEW.discount IS NOT NULL) AND (OLD.discount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'discount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.markup != OLD.markup) OR
            ((NEW.markup IS NULL) AND (OLD.markup IS NOT NULL)) OR
            ((NEW.markup IS NOT NULL) AND (OLD.markup IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'markup'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.nature != OLD.nature) OR
            ((NEW.nature IS NULL) AND (OLD.nature IS NOT NULL)) OR
            ((NEW.nature IS NOT NULL) AND (OLD.nature IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'nature'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.rate != OLD.rate) OR
            ((NEW.rate IS NULL) AND (OLD.rate IS NOT NULL)) OR
            ((NEW.rate IS NOT NULL) AND (OLD.rate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'rate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.slipName != OLD.slipName) OR
            ((NEW.slipName IS NULL) AND (OLD.slipName IS NOT NULL)) OR
            ((NEW.slipName IS NOT NULL) AND (OLD.slipName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'slipName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.typeID != OLD.typeID) OR
            ((NEW.typeID IS NULL) AND (OLD.typeID IS NOT NULL)) OR
            ((NEW.typeID IS NOT NULL) AND (OLD.typeID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'typeID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.units != OLD.units) OR
            ((NEW.units IS NULL) AND (OLD.units IS NOT NULL)) OR
            ((NEW.units IS NOT NULL) AND (OLD.units IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'units'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax1 != OLD.useTax1) OR
            ((NEW.useTax1 IS NULL) AND (OLD.useTax1 IS NOT NULL)) OR
            ((NEW.useTax1 IS NOT NULL) AND (OLD.useTax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax2 != OLD.useTax2) OR
            ((NEW.useTax2 IS NULL) AND (OLD.useTax2 IS NOT NULL)) OR
            ((NEW.useTax2 IS NOT NULL) AND (OLD.useTax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.recurringInvoiceID != OLD.recurringInvoiceID) OR
            ((NEW.recurringInvoiceID IS NULL) AND (OLD.recurringInvoiceID IS NOT NULL)) OR
            ((NEW.recurringInvoiceID IS NOT NULL) AND (OLD.recurringInvoiceID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'recurringInvoiceID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_sliptemplate_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS SlipTemplate_change_log_trigger ON SlipTemplate;
CREATE TRIGGER SlipTemplate_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON SlipTemplate FOR EACH ROW EXECUTE PROCEDURE mc_sliptemplate_change_log(24);
CREATE OR REPLACE FUNCTION mc_statement_change_log() RETURNS TRIGGER AS $mc_statement_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.clientID != OLD.clientID) OR
            ((NEW.clientID IS NULL) AND (OLD.clientID IS NOT NULL)) OR
            ((NEW.clientID IS NOT NULL) AND (OLD.clientID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'clientID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.billingsFileID != OLD.billingsFileID) OR
            ((NEW.billingsFileID IS NULL) AND (OLD.billingsFileID IS NOT NULL)) OR
            ((NEW.billingsFileID IS NOT NULL) AND (OLD.billingsFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'billingsFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userFileID != OLD.userFileID) OR
            ((NEW.userFileID IS NULL) AND (OLD.userFileID IS NOT NULL)) OR
            ((NEW.userFileID IS NOT NULL) AND (OLD.userFileID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userFileID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.sentDate != OLD.sentDate) OR
            ((NEW.sentDate IS NULL) AND (OLD.sentDate IS NOT NULL)) OR
            ((NEW.sentDate IS NOT NULL) AND (OLD.sentDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'sentDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.fromDate != OLD.fromDate) OR
            ((NEW.fromDate IS NULL) AND (OLD.fromDate IS NOT NULL)) OR
            ((NEW.fromDate IS NOT NULL) AND (OLD.fromDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'fromDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.toDate != OLD.toDate) OR
            ((NEW.toDate IS NULL) AND (OLD.toDate IS NOT NULL)) OR
            ((NEW.toDate IS NOT NULL) AND (OLD.toDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'toDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.totalBalance != OLD.totalBalance) OR
            ((NEW.totalBalance IS NULL) AND (OLD.totalBalance IS NOT NULL)) OR
            ((NEW.totalBalance IS NOT NULL) AND (OLD.totalBalance IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'totalBalance'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.currentDue != OLD.currentDue) OR
            ((NEW.currentDue IS NULL) AND (OLD.currentDue IS NOT NULL)) OR
            ((NEW.currentDue IS NOT NULL) AND (OLD.currentDue IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'currentDue'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.overdue30Days != OLD.overdue30Days) OR
            ((NEW.overdue30Days IS NULL) AND (OLD.overdue30Days IS NOT NULL)) OR
            ((NEW.overdue30Days IS NOT NULL) AND (OLD.overdue30Days IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'overdue30Days'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.overdue60Days != OLD.overdue60Days) OR
            ((NEW.overdue60Days IS NULL) AND (OLD.overdue60Days IS NOT NULL)) OR
            ((NEW.overdue60Days IS NOT NULL) AND (OLD.overdue60Days IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'overdue60Days'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.overdue90Days != OLD.overdue90Days) OR
            ((NEW.overdue90Days IS NULL) AND (OLD.overdue90Days IS NOT NULL)) OR
            ((NEW.overdue90Days IS NOT NULL) AND (OLD.overdue90Days IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'overdue90Days'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.overdueOver90Days != OLD.overdueOver90Days) OR
            ((NEW.overdueOver90Days IS NULL) AND (OLD.overdueOver90Days IS NOT NULL)) OR
            ((NEW.overdueOver90Days IS NOT NULL) AND (OLD.overdueOver90Days IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'overdueOver90Days'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.statementNumber != OLD.statementNumber) OR
            ((NEW.statementNumber IS NULL) AND (OLD.statementNumber IS NOT NULL)) OR
            ((NEW.statementNumber IS NOT NULL) AND (OLD.statementNumber IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'statementNumber'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_statement_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Statement_change_log_trigger ON Statement;
CREATE TRIGGER Statement_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Statement FOR EACH ROW EXECUTE PROCEDURE mc_statement_change_log(25);
CREATE OR REPLACE FUNCTION mc_tax_change_log() RETURNS TRIGGER AS $mc_tax_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.active != OLD.active) OR
            ((NEW.active IS NULL) AND (OLD.active IS NOT NULL)) OR
            ((NEW.active IS NOT NULL) AND (OLD.active IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'active'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.compound != OLD.compound) OR
            ((NEW.compound IS NULL) AND (OLD.compound IS NOT NULL)) OR
            ((NEW.compound IS NOT NULL) AND (OLD.compound IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'compound'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.orderIndex != OLD.orderIndex) OR
            ((NEW.orderIndex IS NULL) AND (OLD.orderIndex IS NOT NULL)) OR
            ((NEW.orderIndex IS NOT NULL) AND (OLD.orderIndex IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'orderIndex'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.parentTaxID != OLD.parentTaxID) OR
            ((NEW.parentTaxID IS NULL) AND (OLD.parentTaxID IS NOT NULL)) OR
            ((NEW.parentTaxID IS NOT NULL) AND (OLD.parentTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'parentTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.rate != OLD.rate) OR
            ((NEW.rate IS NULL) AND (OLD.rate IS NOT NULL)) OR
            ((NEW.rate IS NOT NULL) AND (OLD.rate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'rate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.registrationNum != OLD.registrationNum) OR
            ((NEW.registrationNum IS NULL) AND (OLD.registrationNum IS NOT NULL)) OR
            ((NEW.registrationNum IS NOT NULL) AND (OLD.registrationNum IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'registrationNum'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_tax_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS Tax_change_log_trigger ON Tax;
CREATE TRIGGER Tax_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON Tax FOR EACH ROW EXECUTE PROCEDURE mc_tax_change_log(26);
CREATE OR REPLACE FUNCTION mc_taxconsolidatedtaxentry_change_log() RETURNS TRIGGER AS $mc_taxconsolidatedtaxentry_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.orderIndex != OLD.orderIndex) OR
            ((NEW.orderIndex IS NULL) AND (OLD.orderIndex IS NOT NULL)) OR
            ((NEW.orderIndex IS NOT NULL) AND (OLD.orderIndex IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'orderIndex'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.taxID != OLD.taxID) OR
            ((NEW.taxID IS NULL) AND (OLD.taxID IS NOT NULL)) OR
            ((NEW.taxID IS NOT NULL) AND (OLD.taxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'taxID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_taxconsolidatedtaxentry_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS TaxConsolidatedTaxEntry_change_log_trigger ON TaxConsolidatedTaxEntry;
CREATE TRIGGER TaxConsolidatedTaxEntry_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON TaxConsolidatedTaxEntry FOR EACH ROW EXECUTE PROCEDURE mc_taxconsolidatedtaxentry_change_log(27);
CREATE OR REPLACE FUNCTION mc_timeentry_change_log() RETURNS TRIGGER AS $mc_timeentry_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.endDateTime != OLD.endDateTime) OR
            ((NEW.endDateTime IS NULL) AND (OLD.endDateTime IS NOT NULL)) OR
            ((NEW.endDateTime IS NOT NULL) AND (OLD.endDateTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'endDateTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppEntityName != OLD.foreignAppEntityName) OR
            ((NEW.foreignAppEntityName IS NULL) AND (OLD.foreignAppEntityName IS NOT NULL)) OR
            ((NEW.foreignAppEntityName IS NOT NULL) AND (OLD.foreignAppEntityName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppEntityName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppImportID != OLD.foreignAppImportID) OR
            ((NEW.foreignAppImportID IS NULL) AND (OLD.foreignAppImportID IS NOT NULL)) OR
            ((NEW.foreignAppImportID IS NOT NULL) AND (OLD.foreignAppImportID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppImportID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppLastTouchDate != OLD.foreignAppLastTouchDate) OR
            ((NEW.foreignAppLastTouchDate IS NULL) AND (OLD.foreignAppLastTouchDate IS NOT NULL)) OR
            ((NEW.foreignAppLastTouchDate IS NOT NULL) AND (OLD.foreignAppLastTouchDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppLastTouchDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppName != OLD.foreignAppName) OR
            ((NEW.foreignAppName IS NULL) AND (OLD.foreignAppName IS NOT NULL)) OR
            ((NEW.foreignAppName IS NOT NULL) AND (OLD.foreignAppName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppUser != OLD.foreignAppUser) OR
            ((NEW.foreignAppUser IS NULL) AND (OLD.foreignAppUser IS NOT NULL)) OR
            ((NEW.foreignAppUser IS NOT NULL) AND (OLD.foreignAppUser IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppUser'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.isManual != OLD.isManual) OR
            ((NEW.isManual IS NULL) AND (OLD.isManual IS NOT NULL)) OR
            ((NEW.isManual IS NOT NULL) AND (OLD.isManual IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'isManual'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.startDateTime != OLD.startDateTime) OR
            ((NEW.startDateTime IS NULL) AND (OLD.startDateTime IS NOT NULL)) OR
            ((NEW.startDateTime IS NOT NULL) AND (OLD.startDateTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'startDateTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.timeSlipID != OLD.timeSlipID) OR
            ((NEW.timeSlipID IS NULL) AND (OLD.timeSlipID IS NOT NULL)) OR
            ((NEW.timeSlipID IS NOT NULL) AND (OLD.timeSlipID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'timeSlipID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.uuid != OLD.uuid) OR
            ((NEW.uuid IS NULL) AND (OLD.uuid IS NOT NULL)) OR
            ((NEW.uuid IS NOT NULL) AND (OLD.uuid IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'uuid'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_timeentry_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS TimeEntry_change_log_trigger ON TimeEntry;
CREATE TRIGGER TimeEntry_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON TimeEntry FOR EACH ROW EXECUTE PROCEDURE mc_timeentry_change_log(28);
CREATE OR REPLACE FUNCTION mc_timeslip_change_log() RETURNS TRIGGER AS $mc_timeslip_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.activeForTiming != OLD.activeForTiming) OR
            ((NEW.activeForTiming IS NULL) AND (OLD.activeForTiming IS NOT NULL)) OR
            ((NEW.activeForTiming IS NOT NULL) AND (OLD.activeForTiming IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'activeForTiming'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.categoryID != OLD.categoryID) OR
            ((NEW.categoryID IS NULL) AND (OLD.categoryID IS NOT NULL)) OR
            ((NEW.categoryID IS NOT NULL) AND (OLD.categoryID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'categoryID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.userID != OLD.userID) OR
            ((NEW.userID IS NULL) AND (OLD.userID IS NOT NULL)) OR
            ((NEW.userID IS NOT NULL) AND (OLD.userID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'userID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.comment != OLD.comment) OR
            ((NEW.comment IS NULL) AND (OLD.comment IS NOT NULL)) OR
            ((NEW.comment IS NOT NULL) AND (OLD.comment IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'comment'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.compoundSecondaryTax != OLD.compoundSecondaryTax) OR
            ((NEW.compoundSecondaryTax IS NULL) AND (OLD.compoundSecondaryTax IS NOT NULL)) OR
            ((NEW.compoundSecondaryTax IS NOT NULL) AND (OLD.compoundSecondaryTax IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'compoundSecondaryTax'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.consolidatedTaxID != OLD.consolidatedTaxID) OR
            ((NEW.consolidatedTaxID IS NULL) AND (OLD.consolidatedTaxID IS NOT NULL)) OR
            ((NEW.consolidatedTaxID IS NOT NULL) AND (OLD.consolidatedTaxID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'consolidatedTaxID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.discount != OLD.discount) OR
            ((NEW.discount IS NULL) AND (OLD.discount IS NOT NULL)) OR
            ((NEW.discount IS NOT NULL) AND (OLD.discount IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'discount'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.distance != OLD.distance) OR
            ((NEW.distance IS NULL) AND (OLD.distance IS NOT NULL)) OR
            ((NEW.distance IS NOT NULL) AND (OLD.distance IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'distance'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.dueDate != OLD.dueDate) OR
            ((NEW.dueDate IS NULL) AND (OLD.dueDate IS NOT NULL)) OR
            ((NEW.dueDate IS NOT NULL) AND (OLD.dueDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'dueDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.duration != OLD.duration) OR
            ((NEW.duration IS NULL) AND (OLD.duration IS NOT NULL)) OR
            ((NEW.duration IS NOT NULL) AND (OLD.duration IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'duration'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.endDateTime != OLD.endDateTime) OR
            ((NEW.endDateTime IS NULL) AND (OLD.endDateTime IS NOT NULL)) OR
            ((NEW.endDateTime IS NOT NULL) AND (OLD.endDateTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'endDateTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppEntityName != OLD.foreignAppEntityName) OR
            ((NEW.foreignAppEntityName IS NULL) AND (OLD.foreignAppEntityName IS NOT NULL)) OR
            ((NEW.foreignAppEntityName IS NOT NULL) AND (OLD.foreignAppEntityName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppEntityName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppImportID != OLD.foreignAppImportID) OR
            ((NEW.foreignAppImportID IS NULL) AND (OLD.foreignAppImportID IS NOT NULL)) OR
            ((NEW.foreignAppImportID IS NOT NULL) AND (OLD.foreignAppImportID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppImportID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppLastTouchDate != OLD.foreignAppLastTouchDate) OR
            ((NEW.foreignAppLastTouchDate IS NULL) AND (OLD.foreignAppLastTouchDate IS NOT NULL)) OR
            ((NEW.foreignAppLastTouchDate IS NOT NULL) AND (OLD.foreignAppLastTouchDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppLastTouchDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppName != OLD.foreignAppName) OR
            ((NEW.foreignAppName IS NULL) AND (OLD.foreignAppName IS NOT NULL)) OR
            ((NEW.foreignAppName IS NOT NULL) AND (OLD.foreignAppName IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppName'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.foreignAppUser != OLD.foreignAppUser) OR
            ((NEW.foreignAppUser IS NULL) AND (OLD.foreignAppUser IS NOT NULL)) OR
            ((NEW.foreignAppUser IS NOT NULL) AND (OLD.foreignAppUser IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'foreignAppUser'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.iCalUID != OLD.iCalUID) OR
            ((NEW.iCalUID IS NULL) AND (OLD.iCalUID IS NOT NULL)) OR
            ((NEW.iCalUID IS NOT NULL) AND (OLD.iCalUID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'iCalUID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoiceID != OLD.invoiceID) OR
            ((NEW.invoiceID IS NULL) AND (OLD.invoiceID IS NOT NULL)) OR
            ((NEW.invoiceID IS NOT NULL) AND (OLD.invoiceID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoiceID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoicedDate != OLD.invoicedDate) OR
            ((NEW.invoicedDate IS NULL) AND (OLD.invoicedDate IS NOT NULL)) OR
            ((NEW.invoicedDate IS NOT NULL) AND (OLD.invoicedDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoicedDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.markup != OLD.markup) OR
            ((NEW.markup IS NULL) AND (OLD.markup IS NOT NULL)) OR
            ((NEW.markup IS NOT NULL) AND (OLD.markup IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'markup'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.mileageType != OLD.mileageType) OR
            ((NEW.mileageType IS NULL) AND (OLD.mileageType IS NOT NULL)) OR
            ((NEW.mileageType IS NOT NULL) AND (OLD.mileageType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'mileageType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.nature != OLD.nature) OR
            ((NEW.nature IS NULL) AND (OLD.nature IS NOT NULL)) OR
            ((NEW.nature IS NOT NULL) AND (OLD.nature IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'nature'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.rate != OLD.rate) OR
            ((NEW.rate IS NULL) AND (OLD.rate IS NOT NULL)) OR
            ((NEW.rate IS NOT NULL) AND (OLD.rate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'rate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.roundTime != OLD.roundTime) OR
            ((NEW.roundTime IS NULL) AND (OLD.roundTime IS NOT NULL)) OR
            ((NEW.roundTime IS NOT NULL) AND (OLD.roundTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'roundTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.startDateTime != OLD.startDateTime) OR
            ((NEW.startDateTime IS NULL) AND (OLD.startDateTime IS NOT NULL)) OR
            ((NEW.startDateTime IS NOT NULL) AND (OLD.startDateTime IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'startDateTime'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1 != OLD.tax1) OR
            ((NEW.tax1 IS NULL) AND (OLD.tax1 IS NOT NULL)) OR
            ((NEW.tax1 IS NOT NULL) AND (OLD.tax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax1Name != OLD.tax1Name) OR
            ((NEW.tax1Name IS NULL) AND (OLD.tax1Name IS NOT NULL)) OR
            ((NEW.tax1Name IS NOT NULL) AND (OLD.tax1Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax1Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2 != OLD.tax2) OR
            ((NEW.tax2 IS NULL) AND (OLD.tax2 IS NOT NULL)) OR
            ((NEW.tax2 IS NOT NULL) AND (OLD.tax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.tax2Name != OLD.tax2Name) OR
            ((NEW.tax2Name IS NULL) AND (OLD.tax2Name IS NOT NULL)) OR
            ((NEW.tax2Name IS NOT NULL) AND (OLD.tax2Name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'tax2Name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.timeSlipRefID != OLD.timeSlipRefID) OR
            ((NEW.timeSlipRefID IS NULL) AND (OLD.timeSlipRefID IS NOT NULL)) OR
            ((NEW.timeSlipRefID IS NOT NULL) AND (OLD.timeSlipRefID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'timeSlipRefID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.total != OLD.total) OR
            ((NEW.total IS NULL) AND (OLD.total IS NOT NULL)) OR
            ((NEW.total IS NOT NULL) AND (OLD.total IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'total'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.typeID != OLD.typeID) OR
            ((NEW.typeID IS NULL) AND (OLD.typeID IS NOT NULL)) OR
            ((NEW.typeID IS NOT NULL) AND (OLD.typeID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'typeID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.units != OLD.units) OR
            ((NEW.units IS NULL) AND (OLD.units IS NOT NULL)) OR
            ((NEW.units IS NOT NULL) AND (OLD.units IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'units'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax1 != OLD.useTax1) OR
            ((NEW.useTax1 IS NULL) AND (OLD.useTax1 IS NOT NULL)) OR
            ((NEW.useTax1 IS NOT NULL) AND (OLD.useTax1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.useTax2 != OLD.useTax2) OR
            ((NEW.useTax2 IS NULL) AND (OLD.useTax2 IS NOT NULL)) OR
            ((NEW.useTax2 IS NOT NULL) AND (OLD.useTax2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'useTax2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.uuid != OLD.uuid) OR
            ((NEW.uuid IS NULL) AND (OLD.uuid IS NOT NULL)) OR
            ((NEW.uuid IS NOT NULL) AND (OLD.uuid IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'uuid'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.invoicedProjectID != OLD.invoicedProjectID) OR
            ((NEW.invoicedProjectID IS NULL) AND (OLD.invoicedProjectID IS NOT NULL)) OR
            ((NEW.invoicedProjectID IS NOT NULL) AND (OLD.invoicedProjectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'invoicedProjectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.totalCached != OLD.totalCached) OR
            ((NEW.totalCached IS NULL) AND (OLD.totalCached IS NOT NULL)) OR
            ((NEW.totalCached IS NOT NULL) AND (OLD.totalCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'totalCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.durationCached != OLD.durationCached) OR
            ((NEW.durationCached IS NULL) AND (OLD.durationCached IS NOT NULL)) OR
            ((NEW.durationCached IS NOT NULL) AND (OLD.durationCached IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'durationCached'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.geoLocationStart != OLD.geoLocationStart) OR
            ((NEW.geoLocationStart IS NULL) AND (OLD.geoLocationStart IS NOT NULL)) OR
            ((NEW.geoLocationStart IS NOT NULL) AND (OLD.geoLocationStart IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'geoLocationStart'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.geoLocationEnd != OLD.geoLocationEnd) OR
            ((NEW.geoLocationEnd IS NULL) AND (OLD.geoLocationEnd IS NOT NULL)) OR
            ((NEW.geoLocationEnd IS NOT NULL) AND (OLD.geoLocationEnd IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'geoLocationEnd'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.workflowState != OLD.workflowState) OR
            ((NEW.workflowState IS NULL) AND (OLD.workflowState IS NOT NULL)) OR
            ((NEW.workflowState IS NOT NULL) AND (OLD.workflowState IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'workflowState'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.approvedByUserID != OLD.approvedByUserID) OR
            ((NEW.approvedByUserID IS NULL) AND (OLD.approvedByUserID IS NOT NULL)) OR
            ((NEW.approvedByUserID IS NOT NULL) AND (OLD.approvedByUserID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'approvedByUserID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.approvedDate != OLD.approvedDate) OR
            ((NEW.approvedDate IS NULL) AND (OLD.approvedDate IS NOT NULL)) OR
            ((NEW.approvedDate IS NOT NULL) AND (OLD.approvedDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'approvedDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra1 != OLD.extra1) OR
            ((NEW.extra1 IS NULL) AND (OLD.extra1 IS NOT NULL)) OR
            ((NEW.extra1 IS NOT NULL) AND (OLD.extra1 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra1'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra2 != OLD.extra2) OR
            ((NEW.extra2 IS NULL) AND (OLD.extra2 IS NOT NULL)) OR
            ((NEW.extra2 IS NOT NULL) AND (OLD.extra2 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra2'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra3 != OLD.extra3) OR
            ((NEW.extra3 IS NULL) AND (OLD.extra3 IS NOT NULL)) OR
            ((NEW.extra3 IS NOT NULL) AND (OLD.extra3 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra3'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.extra4 != OLD.extra4) OR
            ((NEW.extra4 IS NULL) AND (OLD.extra4 IS NOT NULL)) OR
            ((NEW.extra4 IS NOT NULL) AND (OLD.extra4 IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'extra4'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_timeslip_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS TimeSlip_change_log_trigger ON TimeSlip;
CREATE TRIGGER TimeSlip_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON TimeSlip FOR EACH ROW EXECUTE PROCEDURE mc_timeslip_change_log(29);
CREATE OR REPLACE FUNCTION mc_timesliptype_change_log() RETURNS TRIGGER AS $mc_timesliptype_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.typeCode != OLD.typeCode) OR
            ((NEW.typeCode IS NULL) AND (OLD.typeCode IS NOT NULL)) OR
            ((NEW.typeCode IS NOT NULL) AND (OLD.typeCode IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'typeCode'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_timesliptype_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS TimeSlipType_change_log_trigger ON TimeSlipType;
CREATE TRIGGER TimeSlipType_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON TimeSlipType FOR EACH ROW EXECUTE PROCEDURE mc_timesliptype_change_log(30);
CREATE OR REPLACE FUNCTION mc_urlreference_change_log() RETURNS TRIGGER AS $mc_urlreference_change_log_body$
DECLARE
    return_rec RECORD; -- hack comment
    changed_cols varchar := ''; -- hack comment
    changed_cols_length integer; -- hack comment
    operation_type varchar; -- hack comment
    table_ident integer; -- hack comment
    record_id bigint; -- hack comment
    current_client_id varchar; -- hack comment
    current_user_id bigint; -- hack comment
BEGIN
    IF (TG_OP = 'DELETE') THEN
        return_rec := OLD; -- hack comment
        operation_type := 'D'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'INSERT') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'I'; -- hack comment
        changed_cols_length := 1; -- hack comment
    ELSIF (TG_OP = 'UPDATE') THEN
        return_rec := NEW; -- hack comment
        operation_type := 'U'; -- hack comment
        
        IF ((NEW.createDate != OLD.createDate) OR
            ((NEW.createDate IS NULL) AND (OLD.createDate IS NOT NULL)) OR
            ((NEW.createDate IS NOT NULL) AND (OLD.createDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'createDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.kind != OLD.kind) OR
            ((NEW.kind IS NULL) AND (OLD.kind IS NOT NULL)) OR
            ((NEW.kind IS NOT NULL) AND (OLD.kind IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'kind'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.modifyDate != OLD.modifyDate) OR
            ((NEW.modifyDate IS NULL) AND (OLD.modifyDate IS NOT NULL)) OR
            ((NEW.modifyDate IS NOT NULL) AND (OLD.modifyDate IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'modifyDate'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.name != OLD.name) OR
            ((NEW.name IS NULL) AND (OLD.name IS NOT NULL)) OR
            ((NEW.name IS NOT NULL) AND (OLD.name IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'name'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.projectID != OLD.projectID) OR
            ((NEW.projectID IS NULL) AND (OLD.projectID IS NOT NULL)) OR
            ((NEW.projectID IS NOT NULL) AND (OLD.projectID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'projectID'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.url != OLD.url) OR
            ((NEW.url IS NULL) AND (OLD.url IS NOT NULL)) OR
            ((NEW.url IS NOT NULL) AND (OLD.url IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'url'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.urlType != OLD.urlType) OR
            ((NEW.urlType IS NULL) AND (OLD.urlType IS NOT NULL)) OR
            ((NEW.urlType IS NOT NULL) AND (OLD.urlType IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'urlType'; -- hack comment 
        END IF; -- hack comment 
        IF ((NEW.fileStorageID != OLD.fileStorageID) OR
            ((NEW.fileStorageID IS NULL) AND (OLD.fileStorageID IS NOT NULL)) OR
            ((NEW.fileStorageID IS NOT NULL) AND (OLD.fileStorageID IS NULL))) THEN
            changed_cols := changed_cols || ',' || 'fileStorageID'; -- hack comment 
        END IF; -- hack comment 
        
        changed_cols_length := character_length(changed_cols); -- hack comment
        IF (changed_cols_length != 0) THEN -- hack comment
            changed_cols := substring(changed_cols from 2 for (changed_cols_length - 1)); -- hack comment
        END IF; -- hack comment
    END IF; -- hack comment
    
    table_ident := TG_ARGV[0]; -- hack comment
    record_id := return_rec._rowid; -- hack comment
    
    IF ((select uses_in_memory_connectionvalues())) THEN -- hack comment
        current_client_id := (SELECT get_connection_value_str('client_id')); -- hack comment
        current_user_id := (SELECT get_connection_value_int('user_id')); -- hack comment
    ELSE -- hack comment
        current_client_id := (SELECT client_id FROM ConnectionValues); -- hack comment
        current_user_id := (SELECT user_id FROM ConnectionValues); -- hack comment
    END IF; -- hack comment
    
    IF (changed_cols_length != 0) THEN -- hack comment
        
        INSERT INTO change_log (table_id, primary_key, operation, changed_columns, client_id, user_id) VALUES (table_ident, record_id, operation_type, changed_cols, current_client_id, current_user_id); -- hack comment
    END IF; -- hack comment

    return return_rec; -- hack comment
END; -- hack comment
$mc_urlreference_change_log_body$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS URLReference_change_log_trigger ON URLReference;
CREATE TRIGGER URLReference_change_log_trigger AFTER INSERT OR UPDATE OR DELETE ON URLReference FOR EACH ROW EXECUTE PROCEDURE mc_urlreference_change_log(31);
CREATE OR REPLACE VIEW mc_change_log (_rowid,_timestamp,table_id,table_name,primary_key,operation,changed_columns,client_id,user_id,user_name) AS SELECT t1._rowid, t1._timestamp, t1.table_id, t2.table_name, t1.primary_key, t1.operation, t1.changed_columns, t1.client_id, t1.user_id, t3.name FROM change_log t1 INNER JOIN change_table t2 ON (t1.table_id=t2._rowid) LEFT OUTER JOIN BIUser t3 ON (t1.user_id=t3._rowid);
COMMIT;
