52 lines
2.2 KiB
XML
52 lines
2.2 KiB
XML
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
|
<databaseChangeLog
|
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
|
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
|
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.0.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.23.xsd">
|
|
<changeSet id="23-09-2024_3" author="Harish Bagora" runAlways="true">
|
|
<sql splitStatements="false">
|
|
DO $$
|
|
DECLARE
|
|
r RECORD;
|
|
BEGIN
|
|
-- Loop through all tables in the schema that have the 'updated_date' column
|
|
FOR r IN (
|
|
SELECT table_name
|
|
FROM information_schema.columns
|
|
WHERE column_name = 'updated_date'
|
|
AND table_schema = 'gepafin_schema'
|
|
)
|
|
LOOP
|
|
EXECUTE format(
|
|
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_updated_date_%I
|
|
BEFORE UPDATE ON gepafin_schema.%I
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION gepafin_schema.clock_timestamp_updated_date_column()',
|
|
r.table_name, r.table_name
|
|
);
|
|
END LOOP;
|
|
|
|
-- Loop through all tables in the schema that have the 'created_date' column
|
|
FOR r IN (
|
|
SELECT table_name
|
|
FROM information_schema.columns
|
|
WHERE column_name = 'created_date'
|
|
AND table_schema = 'gepafin_schema'
|
|
)
|
|
LOOP
|
|
EXECUTE format(
|
|
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_created_date_%I
|
|
BEFORE INSERT ON gepafin_schema.%I
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION gepafin_schema.clock_timestamp_created_date_column()',
|
|
r.table_name, r.table_name
|
|
);
|
|
END LOOP;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
</sql>
|
|
</changeSet>
|
|
</databaseChangeLog>
|