This is a tool made by me and made for me, to solve a very specific problem: version-control sqlite.
I love git and sqlite. Both are very reliable and feature-rich. I use them a lot. One problem is that it's very difficult to version-control an sqlite DB with git. You can add the database file to the git repository, but git's not very good at dealing with binary files. You can't git diff binary files, you can't git blame them. Also, git works better with many small files than a single huge file.
So I made this tool. I'm satisfied with it, and I hope you like it too!
- Build from source
git clone https://github.com/baehyunsol/stfg
cd stfg
cargo build --release- Build with cargo
cargo install stfg- Use pre-built binaries
Coming soon!
git commityour database
# This will create a directory `db/` and dump the data to the directory.
# If `db/` already exists, it removes files in the directory. So be careful!
stfg to-git your-database.db -o db/
# Then, run whatever git command you want.
git add db
git commitgit checkoutolder version of your database
git checkout older-version-of-your-database
# Let's assume that `db/` is an output of `stfg to-git` command.
# It overwrites `your-database.db` if it already exists.
stfg from-git db/ -o your-database.db
# Now `your-database.db` contains an older version of your data.git diffbetween 2 versions of your database
# Let's assume that `db/` is an output of `stfg to-git` command.
# stfg creates a subdirectory per table under `db/`, so you can
# easily browse the contents of each table.
git diff HEAD~1:db/your_table_name HEAD:db/your_table_name- Why not just use
.dumpcommand of sqlite?
Yeah that works, and many of you might find that better than my solution. But I think my solution is more git-friendly because 1) it splits the database into small files instead of creating a single huge file and 2) it guarantees each field of the database is exactly one line in a file.
- Can I use this in production?
I don't think so. It's my personal project. There must be a lot of rough edges. Feedbacks and contributions are welcome!!