graphile/migrate

Placeholder -> Mustache/handlebars template?

tonyxiao opened this issue · 4 comments

I often find myself repeating statements when writing raw sql. For example creating 3 different tables with extremely similar structure & permissions. Given that graphile already has the concept of placeholders, I wonder if it makes sense to implement actual templating using something like handlebars so one could do things like loops to further reduce duplication in sql

benjie commented

This will never be a feature of Graphile Migrate itself, but you could absolutely write queries into the migration folder based on some preprocessing you do elsewhere 👍

Note that the placeholders are designed to be compatible with psql and are specifically there to handle things like roles/schema names and not much else.

Is it possible hook into the compile step of graphile migrate itself? I saw there seems to be an option in gmrc

benjie commented

No; but at some point I'll be replacing .gmrc.js with a graphile.config.js using the standard Graphile config package that I've built for PostGraphile V5 et al, and this will bring with it new capabilities such as plugins and what not that would allow for you to write a plugin to do this.