0

当我尝试使用终端命令()向下迁移我的基地时,migrate -path scripts -database "postgresql://postgres:postgres@localhost:5439/basename?sslmode=disable" -verbose down我收到了一个错误:error: database driver: unknown driver postgresql (forgotten import?). 如何解决?

4

1 回答 1

1

我认为您需要使用特定标签构建以添加特定驱动程序。

请参阅文档 https://github.com/golang-migrate/migrate/tree/master/cmd/migrate#with-go-toolchain

$ go get -u -d github.com/golang-migrate/migrate/cmd/migrate
$ cd $GOPATH/src/github.com/golang-migrate/migrate/cmd/migrate
$ git checkout $TAG  # e.g. v4.1.0
$ go build -tags 'postgres' -ldflags="-X main.Version=$(git describe --tags)" -o $GOPATH/bin/migrate $GOPATH/src/github.com/golang-migrate/migrate/cmd/migrate

于 2020-08-18T16:43:42.523 回答