migrate
migrate copied to clipboard
ability to use env variables
Is your feature request related to a problem? Please describe. when creating foreign tables e.g. in PG via pg_fdw or in clickhouse you need a password for the connection string. it should be possible to to inject those from env variables
Describe the solution you'd like
flag to be able to run sql statements through text/template or a similar library and inject all env variables
I use envsubst on the folder that contains the sql files prior to running migrate...
It would be very useful to have text/template applied for migrations. One possible use case is to inject a timestamp at execution time. I'm working with MongoDb and when I need to update a collection I would like to copy the previous one with the same name plus a timestamp, something like {{ now }} where now is an injected function time.Now().
https://github.com/golang-migrate/migrate/pull/793
Using good script written for mac & linux, environment variables will be picked from .env in the project root:
https://github.com/golang-migrate/migrate/pull/793#issuecomment-1648765804