Migrate: PostgreSQL connection requires SSL, which sucks for testing

Created on 31 Jul 2019  路  4Comments  路  Source: golang-migrate/migrate

Describe the Bug
I wanted to test go-migrate with PostgreSQL but apparently SSL is enforced all the time.

Steps to Reproduce
Steps to reproduce the behavior:

  1. My migrations look like:
    I have some simple tables created for testing the migrate tools. Content isn't really an issue.
  2. I ran migrate with the following options
    migrate -path migrations -database postgres://postgres:mysecretpassword@localhost:5432 up
  3. See error
    error: pq: SSL is not enabled on the server

Expected Behavior
I wanted to test migrate with a local PostgreSQL but unfortunately I cannot connect with disabled SSL.

Migrate Version
v4.5.0 obtained from homebrew.

Loaded Source Drivers
Source drivers: github-ee, gitlab, go-bindata, godoc-vfs, gcs, file, s3, github

Loaded Database Drivers
Database drivers: cockroach, crdb-postgres, mongodb, mysql, sqlserver, stub, cassandra, clickhouse, cockroachdb, postgres, postgresql, redshift, spanner

Go Version
go version go1.12.1 darwin/amd64

Most helpful comment

Reading through the PostgreSQL documentation made it more clear to me to use the sslmode=disabled parameter. Maybe this should be outlined in the docs of the CLI.

All 4 comments

Reading through the PostgreSQL documentation made it more clear to me to use the sslmode=disabled parameter. Maybe this should be outlined in the docs of the CLI.

The docs could use some reorganization.

We could call out how DSNs/connection strings are dependent on the DB being used in the CLI docs.
@Fohlen Feel free to open a PR with doc changes

migrate -source file://db/migrations/up -database postgres://testing:testing@localhost:5432/testing?sslmode=disabled up

Sslmode query param not working for me

You must use double quote for the db URL, like this:

migrate -source file://./sql/migrations -database "postgres://postgres:@localhost:54321/mydb?sslmode=disable" version

Was this page helpful?
0 / 5 - 0 ratings