This is such a simple and useful SQLite hack.

Get the best out of #git and #sqlite by having your database versioned in a human-readable format:

```
# Create a local git repo and a db file
$ git init
$ sqlite3 ./test.db
sqlite> create table test(id int primary key, value text);
$ git add test.db
# Set the diff format for *.db files
$ git config diff.sqlite3.binary true
$ git config diff.sqlite3.textconv "echo .dump | sqlite3"
$ echo '*.db diff=sqlite3' >> .gitattributes
# Do some stuff with the db
$ sqlite3 ./test.db
sqlite> insert into test values(1, 'a');
sqlite> insert into test values(2, 'b');
sqlite> insert into test values(3, 'c');
sqlite> update test set text = 'aaa' where id = 1;
sqlite> delete from test where id = 3;
# Check the diff
$ git diff
diff --git a/test.db b/test.db
index 9d6e6db..c9a7a08 100644
--- a/test.db
+++ b/test.db
@@ -1,4 +1,6 @@
...
CREATE TABLE test(id int primary key, text text);
+INSERT INTO test VALUES(1,'aaa');
+INSERT INTO test VALUES(2,'b');
COMMIT;
```

garrit.xyz/posts/2023-11-01-tr