Temporal table in PostgreSQL #7
vbilopav
started this conversation in
PostgreSQL
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The following script will add support for temporal tables in PostgreSQL.
It will add two new functions in the
public
schema:temporal_table_trigger
- trigger function that inserts temporal data.This function will create a new schema (source schema plus
__history
) and a new table with temporal data in it.The new table will have the exact same schema without keys and constraints with one extra field -
data_valid_to timestamptz not null default now();
init_temporal_tables
This function initiates the entire temporal tables system by creating trigger
temporal_table_trigger
on each tables It accepts an array of schema names we want to have temporal tables.To call this function for the public schema:
The script:
Beta Was this translation helpful? Give feedback.
All reactions