This PR updates the parsing and formatting of the URI that is used when applying migrations and adds tests for sample input connStrings
As of 94d7d68539b6980cece521b428733f6c344bc268, using a connString with a non-default port number will ignore the custom port and default to 5432 in PgBackend.initializeDB when attempting to run migrations. The current connString formatting code will read pgxCfg.Host but not pgxCfg.Port when generating the new connString
postgresq://localhost:5433/neoq?sslmode=disable - Example input connString
postgresq://localhost/neoq?sslmode=disable&x-migrations-table=neoq_schema_migrations - connString that is actually used by PgBackend to try to apply migrations, note the default 5432 port number will be used since it's not specified
This PR updates the parsing and formatting of the URI that is used when applying migrations and adds tests for sample input connStrings
As of 94d7d68539b6980cece521b428733f6c344bc268, using a connString with a non-default port number will ignore the custom port and default to
5432
inPgBackend.initializeDB
when attempting to run migrations. The current connString formatting code will readpgxCfg.Host
but notpgxCfg.Port
when generating the new connStringpostgresq://localhost:5433/neoq?sslmode=disable
- Example input connStringpostgresq://localhost/neoq?sslmode=disable&x-migrations-table=neoq_schema_migrations
- connString that is actually used by PgBackend to try to apply migrations, note the default5432
port number will be used since it's not specifiedhttps://github.com/acaloiaro/neoq/blob/94d7d68539b6980cece521b428733f6c344bc268/backends/postgres/postgres_backend.go#L356-L361
Note that pq-style URLs are not supported, please let me know if you would like support for them