簡體   English   中英

使用終端命令的 golang-migrate 未知驅動程序 postgresql

[英]golang-migrate unknown driver postgresql using terminal command

當我嘗試使用終端命令( migrate -path scripts -database "postgresql://postgres:postgres@localhost:5439/basename?sslmode=disable" -verbose down )向下遷移我的基礎時,出現錯誤: error: database driver: unknown driver postgresql (forgotten import?) 如何解決?

我認為您需要使用特定標簽構建以添加特定驅動程序。

請參閱文檔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

go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM