我正在使用
Goose
来管理我的 Go
项目迁移。如何从 connection-string
文件中获取 .env
?
goose -dir <migration-directory> mysql "<user>:<password>@tcp(<host>:<port>)/<database-name>" up
在我的 .env 文件中,我设置了以下变量:
然后我使用以下 shell 脚本:
#! /bin/sh
set -a
. .env
set +a
goose -dir <path to migrations> "$@"
然后我运行它而不是 goose 命令,这样我就不必包含任何配置,例如:
./goose.sh up