Use system variables in migrations #352
Replies: 2 comments 3 replies
-
duplicated of #118 Will this feature be added in a near future? @amacneil |
Beta Was this translation helpful? Give feedback.
-
About #118 (comment)
I like the idea of exposing go template syntax as it generally stands out within SQL snippets. I noticed dbmate migration parsing logic already has support for optional arguments So the parsing output mapping could be enhanced to support declaring exposed env vars, migration per migration. i.e. a syntax like This would somewhat mitigate the point
IMHO the complexity added this way would be negligible: add the option to existing ParsedMigrationOptions and use its values to pass the raw sql through go templating (just if/when needed). Side effects like templating syntax conflicts would be limited to migrations having that option enabled, of which migration author should be aware. If it makes sense and need some help I could propose a PR. |
Beta Was this translation helpful? Give feedback.
-
I am encrypting a set of fields with
AES_ENCRYPT
and I would like to use an environment variable to specify the secret key instead of hard-coding it.Example:
I would like
1234
to be some variable like@secret_key
.Does dbmate support this use case?
Beta Was this translation helpful? Give feedback.
All reactions