From a5a24d7384ac3255e7ff130dd8868e561cc466fc Mon Sep 17 00:00:00 2001 From: kyrozetera Date: Tue, 22 Dec 2020 23:54:35 -0600 Subject: [PATCH 1/2] exclude migration_table_name from connection string --- connection_details.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/connection_details.go b/connection_details.go index 76c165b5..29c0ae41 100644 --- a/connection_details.go +++ b/connection_details.go @@ -179,6 +179,10 @@ func (cd *ConnectionDetails) OptionsString(s string) string { } if cd.Options != nil { for k, v := range cd.Options { + if k == "migration_table_name" { + continue + } + s = fmt.Sprintf("%s&%s=%s", s, k, v) } } From d3bdafd9c96d182e3cb6efdeff8ca1fb9ae3f7ff Mon Sep 17 00:00:00 2001 From: kyrozetera Date: Tue, 22 Dec 2020 23:54:51 -0600 Subject: [PATCH 2/2] add test for OptionsString --- connection_details_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/connection_details_test.go b/connection_details_test.go index 4121745a..877c8418 100644 --- a/connection_details_test.go +++ b/connection_details_test.go @@ -84,3 +84,22 @@ func Test_ConnectionDetails_Finalize_NoDB_NoURL(t *testing.T) { err := cd.Finalize() r.Error(err) } + +func Test_ConnectionDetails_OptionsString_Postgres(t *testing.T) { + r := require.New(t) + cd := &ConnectionDetails{ + Dialect: "postgres", + Database: "database", + Host: "host", + Port: "1234", + User: "user", + Password: "pass", + Options: map[string]string{ + "migration_table_name": "migrations", + "sslmode": "require", + }, + } + + r.Equal("sslmode=require", cd.OptionsString("")) + r.Equal("migrations", cd.MigrationTableName()) +}