migrate icon indicating copy to clipboard operation
migrate copied to clipboard

ability to use env variables

Open yannick opened this issue 3 years ago • 4 comments

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

yannick avatar May 31 '22 15:05 yannick

I use envsubst on the folder that contains the sql files prior to running migrate...

mikegleasonjr avatar Jul 05 '22 12:07 mikegleasonjr

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().

webfrank avatar Nov 03 '22 11:11 webfrank

https://github.com/golang-migrate/migrate/pull/793

Bessonov avatar Feb 25 '23 19:02 Bessonov

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

smitpatelx avatar Jul 24 '23 23:07 smitpatelx