Skip to content
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

SQLalchemy upgrade - step one #2979

Merged
merged 18 commits into from
Dec 20, 2023
Merged

SQLalchemy upgrade - step one #2979

merged 18 commits into from
Dec 20, 2023

Conversation

berggren
Copy link
Contributor

@berggren berggren commented Nov 14, 2023

Upgrading sqlalchemy. This PR prepare the current v1.4 codebase to be compatible with v2.0. Below are the tasks in the migration work that has been addressed with this PR.

Prerequisites

  1. Prerequisite Step one - A Working 1.3 Application (ref).
  2. Prerequisite Step two - A Working 1.4 Application (ref).

Migrate to SA 2.0

  1. Migration to 2.0 Step One - Python 3 only (Python 3.6 minimum) (ref).
  2. Migration to 2.0 Step Two - Use RemovedIn20Warnings (ref)
  3. Migration to 2.0 Step Three - Resolve all RemovedIn20Warnings (ref)
    • query.get(id) has been deprecated and we use that in our AclBaseQuery. The 2.x way is to use the db session directly db_session.get(User, 1).
    • Cascading backref has been depracated. This means that any assumption that any dependant model object will. be added to the DB session is not true any more. Refactor to make sure that all objects are explicitly added to the session before any db_session.commit(). This also means that our legacy way of setting default values for db models via init constructor don't work anymore and could lead to subtle bugs. Refactor and remove any init from all models and move defaults to the default= flag to the attribute instead.
  4. Migration to 2.0 Step Four - Use the future flag on Engine (ref)
  5. Migration to 2.0 Step Five - Use the future flag on Session (ref)

Part of #2979

@berggren berggren self-assigned this Nov 21, 2023
@berggren berggren requested a review from jkppr November 21, 2023 11:40
@berggren berggren marked this pull request as ready for review November 21, 2023 11:40
Copy link
Collaborator

@jkppr jkppr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, lgtm

@berggren berggren added this to the Release: 20240207 milestone Dec 19, 2023
@berggren berggren merged commit 07b6b2e into master Dec 20, 2023
27 checks passed
@berggren berggren deleted the sqlalchemy-upgrade branch December 20, 2023 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants