Splitgraph has been acquired by EDB! Read the blog post.

Tracking changes

When you check out a Splitgraph image into a schema, sgr enables change tracking via PostgreSQL audit triggers. When any application writes to that schema, the audit triggers will capture the changes, allowing sgr to package them into new images as a set of delta-compressed patches. This way, keeping track of table history is space efficient.

You can view changes to the current working checkout or between any two images in a repository with the sgr diff command.

You can view the history of all changes to an image with the sgr log command. This shows just the history following the parent chain of an image. Passing -t will make sgr render the history of the whole repository as a tree.

Example

Let's create another example repository and give the new image a tag:

$ sgr example generate example/repo_2
$ sgr sql --schema example/repo_2 "SELECT * FROM demo ORDER BY key"
$ sgr tag example/repo_2 original_data

You can do the next step using any SQL client that can access the PostgreSQL database backing the sgr engine, but sgr provides a shorthand to alter the generated image:

$ sgr example alter example/repo_2

Deleting 2 rows...
Updating 2 rows...
Adding 2 rows...

Let's inspect the current state of the repository:

$ sgr sql --schema example/repo_2 "SELECT * FROM demo ORDER BY key"

You should see that the first two rows are now missing, the second two rows have been altered and two more rows have been added.

Let's compare the demo table to its previous version:

$ sgr diff example/repo_2 -v

Between 97900a827962 and the current working copy:
demo: added 4 rows, removed 4 rows.
- (0, '5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9')
- (1, '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b')
- (2, 'd4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35')
- (3, '4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce')
+ (2, 'd4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35_UPDATED')
+ (3, '4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce_UPDATED')
+ (10, '4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5')
+ (11, '4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c08170a05eeb8')

Table of contents