This documentation provides recommendations on how to proceed when the schema of the source changes.
A new JSON key is first safely ignored. One can regenerate the corresponding derived table and trigger for creating the corresponding column.
However, one should plan to remove soon the mapping entries using that key. Indeed, they may break once the derived tables and triggers are regenerated, as the corresponding column won't appear anymore.
In case of an array, the derived table for the old array is now useless. Please write by hand a SQL script for cleaning the derived table and its trigger.
Not considered at the moment. To be investigated when the situation appears.
Adding a column in a source table will stop the replication (see https://pgdash.io/blog/postgres-replication-gotchas.html) until the same column is added to the corresponding replicated table.
See the dedicated action for migrating the schema.
At the moment only two columns in the mirror tables are used for building derived tables: id
and data
.
However, removing an additional column may break the replication. See the dedicated action for migrating the schema.
We no longer use logical replication, so we do not have issues here.
It does not seems to complain.
This SQL script performs the following actions:
- It regenerates all the derived tables and triggers of a mirror table.
- It populates the derived tables from the mirror table.
- It resumes the replication.
Steps:
- Generate the script (change the parameter values)
cd scripts
python3 create_derived_tables_and_triggers_from_db.py regenerate -t accommodationsopen -u tourismuser -p postgres2 -h localhost -d tourismuser --port 7776
- Publish the SQL script with the prefix
regen-
.
- Write a SQL script adding and removing some columns in the mirror tables
- Publish it
Steps:
- Copy the script to the
sql
and rename it with the latestVxx__
prefix (following the Flyway conventions) - Commit the new file and push it on Github.
The CI runner should recreate the Ontop Docker image. When starting this new image, the container should run the new script (through Flyway) on the slave DB instance.
See infrastructure/utils/flyway/README.md for further information about Flyway, and its manual execution.