0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

golang-migrateでmigrateできない時の確認事項【備忘録】

Posted at

問題

golang-migrateでmigrateしようとするとエラーを吐かれる.
なぜ今roleの問題が発生する?

$ migrate -path db/migration -database "postgres://postgres:pass@localhost:5432/postgres?sslmode=disable" up
$ error: pq: role "postgres" does not exist

対処

先に対処法から紹介.
Path等に誤りがない場合、ローカルでPostgresが起動しているか確認
起動している場合は停止させてから再度migrateを試みると通る!..かもしれない.

ちなみにMacで停止させる場合は以下のコマンドを使う.

$ brew services stop postgresql

原因

ローカルでPostgresが同一のポート(大抵は5432)で動いている場合はローカルの方に接続されてしまうらしい.

参考

Go言語とPostgreSQLで遊ぼう!~マイグレーション編~

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?