I have a double answer. If your sqlite is light enough and often updated, you can add it to the repository without unnecessary consequences / problems.
But readability is reduced for diff, as it is stored as binary.
sqlite3 git diff
Here's how to get git to show that you are well versed:
https://gist.github.com/peteristhegreat/a028bc3b588baaea09ff67f405af2909
git config diff.sqlite3.textconv 'sqlite3 $1 .dump' echo '*.db diff=sqlite3' >> $(git rev-parse --show-toplevel)/.gitattributes
Now that your sqlite db file changes, you can see the change with git diff .
If you want to see only the difference in the schema, just change the .dump to .schema , and it should only make create calls and skip inserts.
convert sqlite3 to and from the repository with clean / smudge
If you want your db file to go to the repository as sql instead of db, you can use the clean / smudge mechanisms in git.
https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion
https://github.com/gilesbowkett/git-smudge-and-clean
I have not tried it yet, but basically whenever you come across a file that is db, git writes a stripped-down version of the file (as SQL commands) using sqlite3 $1 .schema . And then when you check this file from your database, it is converted back to db with cat $1 | sqlite3 cat $1 | sqlite3 .
sqlite3 always saves the latest file
Correct way to track sqlite3 binary in git?
.gitattributes mysqlite3.db merge=keepTheir
Hope this helps.
source share