-
Notifications
You must be signed in to change notification settings - Fork 980
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
Upgrade from psycopg2 to psycopg3 #10742
Conversation
|
|
da2d16a
to
6f4bc75
Compare
I tried to get the migrations to work by using |
Bumps [pytest-postgresql](https://github.com/ClearcodeHQ/pytest-postgresql) from 3.1.3 to 5.0.0. - [Changelog](https://github.com/ClearcodeHQ/pytest-postgresql/blob/main/CHANGES.rst) - [Commits](ClearcodeHQ/pytest-postgresql@v3.1.3...v5.0.0) --- updated-dependencies: - dependency-name: pytest-postgresql dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
6f5f59b
to
b81e8e2
Compare
Co-authored-by: Mike Fiedler <miketheman@gmail.com>
|
This gets the migrations to run, but the
|
The context manager issues a ROLLBACK unless we commit inside it. Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Now that the concept is removed, we need to remove assertions that fail in its absence. Signed-off-by: Mike Fiedler <miketheman@gmail.com>
psycopg2 passed strings, but psycopg 3 uses real types. Use `type_coerce()` instead of `cast()` to have the coercion done in Python, and not emit a `CAST()` in the generated SQL. Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
2627fab
to
52f8dcf
Compare
I added a few more commits - should pass cleanly now, but worth reviewing nonetheless. psycopg 3 now uses "real" types with PG (INET, datetime et al) - something we should continue to work on migrating to SQLAlchemy 2.0 typed model syntax so mismatches and implicit coercion can be handled more cleanly. |
Also just noticed you likely wanna remove |
@@ -55,7 +55,7 @@ def upgrade(): | |||
""" | |||
) | |||
) | |||
conn.execute(sa.text("COMMIT")) | |||
op.get_bind().commit() |
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.
I don't thing we need to go back and change historical migrations at this point other than the minimum to get them working. I just wanted to note somewhere that I think in the future for this pattern, an auto commit block wrapping the while
loop might end up being cleaner.
Closes #13710.