-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add driver for pgx v5 #848
Conversation
54dbdb8
to
402b5ef
Compare
Hey! Quick bump from me? I'm currently running this branch to allow me to use pgx and golang-migrate together. (thanks btw!) Any updates on getting this merged? 😇 |
402b5ef
to
456a5f2
Compare
Rebased on top of master |
Any updates on getting this merged? Appreciate everyone's time. |
Please some prio 🙏 |
456a5f2
to
c198cf3
Compare
Any updates on this PR please? |
Any updates please??? |
Hi @dhui. Would you mind reviewing and consider an approval? We have quite a few platforms waiting for this PR to be merged. Your help, and the help of any maintainer, is greatly appreciated. |
Rebased on top of master again to fix conflicts, and bumped pgx minor versions again. @vincentdaniel it was nice of you to approve this last time, but it didn't look like that granted mergeability, is that correct? |
@treuherz correct, I am not maintainer of the project but I tried my luck anyway to see 🙈 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@treuherz thanks for the PR and apologies for the slow turnaround time. Life has been busy...
I'll also update golang-migrate to only support (and run tests for) Go 1.19 and 1.20
database/pgx/pgx.go
Outdated
var ( | ||
multiStmtDelimiter = []byte(";") | ||
|
||
DefaultMigrationsTable = "schema_migrations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These would need to be exported as well.
I think it's safer and easier to leave the default as v4 (e.g. remove the v4 folder in this PR) and update the README and godocs to also mention that a v5 driver is also available. I think it's fine to offer both v4 and v5 so we can mark v4 as deprecated later. e.g. whenever pgx deprecates v4. Do you know if v4 has already been deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I can do that.
Depends what you mean by deprecated. I think jackc is still applying critical bugfixes to v4 but it's not having significant work done.
database/pgx/v5/README.md
Outdated
@@ -0,0 +1,41 @@ | |||
# pgx | |||
|
|||
Backends are provided for [pgx v4](v4) and [pgx v5](v5). Links to v4 are exported in this package for backwards compatability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be updated
internal/cli/build_pgx.go
Outdated
@@ -4,5 +4,5 @@ | |||
package cli | |||
|
|||
import ( | |||
_ "github.com/golang-migrate/migrate/v4/database/pgx" | |||
_ "github.com/golang-migrate/migrate/v4/database/pgx/v5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Fixes golang-migrate#827 - Move existing driver into database/pgx/v4 - Make exported items into database/pgx into links to database/pgx/v4, marked as Deprecated - Remove most tests in database/pgx, leaving a couple of e2e tests behind to help ensure backwards compatibility. - Mark defunct ErrDatabaseDirty as Deprecated - no code returns it - Bump pgx/v4 dependency - Add test runs for newer Postgres versions
Implemented comments, rebased on master again to resolve go.mod conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@treuherz Thanks for the PR updates. This should be the last round.
README.md
Outdated
@@ -24,7 +24,8 @@ Forked from [mattes/migrate](https://github.com/mattes/migrate) | |||
Database drivers run migrations. [Add a new database?](database/driver.go) | |||
|
|||
* [PostgreSQL](database/postgres) | |||
* [PGX](database/pgx) | |||
* [PGX v4](database/pgx/v4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be database/pgx
database/pgx/v5/pgx.go
Outdated
|
||
func init() { | ||
db := Postgres{} | ||
database.Register("pgx", &db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be registered as pgx5
to avoid a conflict with pgx
(v4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of a few weeks ago, pgx registers its database/sql Driver under pgx/v4
or pgx/v5
, as well as conditionally registering pgx
if it’s not already registered by importing another version (see https://github.com/jackc/pgx/blob/9ae852eb583d2dced83b1d2ffe1c8803dda2c92e/stdlib/sql.go#L94). I’m happy to copy in the conflict-avoidance code or if you prefer just leave it out and have v4 register as pgx and pgx/v4, and v5 only register pgx/v5
I definitely think it would be better to match pgx’s pgx/vN
registration string rather than inventing a new one. I know I didn’t use it in this PR originally but the upstream change is very new!
internal/cli/build_pgxv5.go
Outdated
@@ -0,0 +1,8 @@ | |||
//go:build pgxv5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename this file and tag to pgx5
? The v
is verbose and unnecessary.
Makefile
Outdated
@@ -1,5 +1,5 @@ | |||
SOURCE ?= file go_bindata github github_ee bitbucket aws_s3 google_cloud_storage godoc_vfs gitlab | |||
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx | |||
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx pgxv5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also need to update this to pgx5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@treuherz Could you also update the db registration name?
database/pgx/pgx.go
Outdated
@@ -28,6 +28,7 @@ import ( | |||
func init() { | |||
db := Postgres{} | |||
database.Register("pgx", &db) | |||
database.Register("pgx/v4", &db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Register this as pgx4
since pgx/v4
is verbose. We don't need to be consistent with the upstream. Also, our DSN/connection string parsing uses URL parsing and /
is not a valid scheme character
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
database/pgx/v5/pgx.go
Outdated
@@ -27,7 +27,7 @@ import ( | |||
|
|||
func init() { | |||
db := Postgres{} | |||
database.Register("pgx", &db) | |||
database.Register("pgx/v5", &db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Register as pgx5
for the same reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
can we merge/release this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@treuherz Thanks again for the PR and for addressing my feedback!
Fixes #827
marked as Deprecated
If you'd like the last couple of changes to be broken into a different PR then let me know.