Skip to main content
100%

Create a table to store changes from any of your tables in a log table.

✓ Published0🌍 Public
Aandrewxhill
Last edited Jun 19, 2015
Created on Jun 19, 2015

This example demonstrates a SQL-based version-control system for geospatial data in a CartoDB database. It shows how to create a log table that stores changes from any tracked table, capturing insertions, updates, and deletions with full row data as JSON. The code uses PostgreSQL PL/pgSQL triggers and functions, along with the `row_to_json` and `json_populate_record` functions to serialize and reconstruct records. A trigger on a user-specified table invokes the logging function, storing the geometry, operation type, source ID, and table name in the `version_control` table.

AI-generated description

Similar vizzes