Sqitch Templates
Sqitch has a template mechanism that follows the same design pattern as its migration files. This makes it easy to manage templates with Sqitch itself.
My project directory now contains a templates/
subdirectory. This is just another Sqitch project top_dir
, but for templates. The sqitch.conf
file in that directory looks like this:
[core]
engine = pg
template_directory =
extension = tmpl
[engine "pg"]
registry = illegal-registry
client = none
template_directory =
This means new “migrations” carry the .tmpl
extension, and deployments are intentionally broken. I create a new template with
sqitch -C templates add new_template_name
In the project directory, the parent to templates/
, use this in sqitch.conf
:
[add]
template_directory = templates
This also works in the normal user-wide template directory ${HOME}/.sqitch/templates
or in the project. I do both, borrowing templates into the project, and then developing them there, merging back into the user-wide templates as appropriate.
It’s simple yet effective!