~bigbes/core-go: f0b0e702

Add sourcehut-migrate, a unified DB migration tool

This tool will replace both the old `srht-migrate` as well as all
`<SERVICE>-migrate` tools, but services need to be migrated over to it
one by one. This tool is based on brant [1].

Invocation in both production and development can be as simple as:

    sourcehut-migrate <SERVICE> up

The tool will read a config like a regular service (first in ., then
/etc/sr.ht, etc.). The database connection details are taken from the
config. To facilitate development, the tool will check if a folder
./migrations exists; if it does, migrations will be loaded from there.
If no ./migrations folder was found, it will look for migrations in
`<ASSETS>/migrations/<SERVICE>`, where <ASSETS> is also taken from the
config, with a default of `/usr/share/sourcehut`.

For an explanation of the available commands, see brant [1].

This tool also supports a simple command to initialize a newly created
database to the current version (much like the `<SERVICE>-initdb` tools
used to):

    sourcehut-migrate <SERVICE> stamp head

will automatically set the database version to whatever the latest
available migration version is.

[1]: https://git.sr.ht/~bitfehler/brant

Conrad Hoffmann <ch@bitfehler.net> — 2025-06-06 09:39:04 UTC

Commit f0b0e7025d0c6893a522541a320faae5193bf356view raw patch

Parent(s): bdb0f7e8

3 changed file(s)

FileStatus+
cmd/sourcehut-migrate/main.go A +97
go.mod M +23 -13
go.sum M +58 -30