default
.rst
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sync_all_temporal_tables(schema_name text)
Description
Synchronizes all temporal tables in a schema. Returns JSON with details of all changes made.
Parameters
Name
Type
Mode
schema_name
text
IN
Definition
declare table_record record; all_results jsonb := '[]'::jsonb; sync_result jsonb; begin -- Find all tables that have corresponding history tables for table_record in select distinct t.table_name as tbl_name from information_schema.tables t where t.table_schema = sync_all_temporal_tables.schema_name and t.table_type = 'BASE TABLE' and exists ( select 1 from information_schema.tables h where h.table_schema = sync_all_temporal_tables.schema_name and h.table_name = t.table_name || '_history' ) and t.table_name not like '%_history' order by t.table_name loop raise notice 'Syncing temporal table: %.%', sync_all_temporal_tables.schema_name, table_record.tbl_name; sync_result := sync_temporal_table_schema(sync_all_temporal_tables.schema_name, table_record.tbl_name); all_results := all_results || sync_result; end loop; return jsonb_build_object( 'schema', sync_all_temporal_tables.schema_name, 'tables_synced', jsonb_array_length(all_results), 'results', all_results ); end;