You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example, `deleted_history` is generic enough that it could be the "history" table for several other relations, since it uses columns `schemaname` and `tablename`, and `identifier` as the flexible `JSONB` data type to allow for different types of primary key. This avoids the overhead of needing a new `_history` table for every relation created - all the data, including history, is captured in the `git` column. The `identifier` column is only used for lookups.
283
286
284
-
### Configuraton
287
+
### Options
288
+
289
+
#### Commit messages
285
290
286
291
You can pass a custom commit message and author by pre-loading the `git` property with `commit` details, which can include a commit message and user info:
287
292
@@ -327,6 +332,8 @@ where id = 2
327
332
}
328
333
```
329
334
335
+
#### Log depth
336
+
330
337
`git_log` also accepts a `depth` parameter to limit the amount of history that is fetched:
331
338
332
339
```sql
@@ -380,6 +387,27 @@ where id = 2
380
387
381
388
By setting `depth := 1`, only the most recent change is returned.
382
389
390
+
#### Tags
391
+
392
+
You can pass `tags` to the git object. The below example uses a convention of tagging with the day, month, and year so it will later be easy to restore to previous versions:
`git_resolve` gives you a json representation of a prior version of a row, which can be used for backup and restore. The first argument is a `git` json value, the second value is a valid git ref string.
@@ -426,7 +454,32 @@ returning id, text
426
454
}
427
455
```
428
456
429
-
Or a similar technique can restore a deleted item:
457
+
If you used `tags` as described above, you can take advantage of them to restore to a known-good state easily:
// In this example, `deleted_history` is generic enough that it could be the "history" table for several other relations, since it uses columns `schemaname` and `tablename`, and `identifier` as the flexible `JSONB` data type to allow for different types of primary key. This avoids the overhead of needing a new `_history` table for every relation created - all the data, including history, is captured in the `git` column. The `identifier` column is only used for lookups.
281
281
282
-
// ### Configuraton
282
+
// ### Options
283
+
284
+
// #### Commit messages
283
285
284
286
// You can pass a custom commit message and author by pre-loading the `git` property with `commit` details, which can include a commit message and user info:
// By setting `depth := 1`, only the most recent change is returned.
380
384
385
+
// #### Tags
386
+
387
+
// You can pass `tags` to the git object. The below example uses a convention of tagging with the day, month, and year so it will later be easy to restore to previous versions:
// `git_resolve` gives you a json representation of a prior version of a row, which can be used for backup and restore. The first argument is a `git` json value, the second value is a valid git ref string.
0 commit comments