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

Upgrade SQLAlchemy 1.4 -> 2.0 #2978

Open
9 of 10 tasks
berggren opened this issue Nov 13, 2023 · 0 comments
Open
9 of 10 tasks

Upgrade SQLAlchemy 1.4 -> 2.0 #2978

berggren opened this issue Nov 13, 2023 · 0 comments
Assignees
Labels
Code Health Code health improvements

Comments

@berggren
Copy link
Contributor

berggren commented Nov 13, 2023

Prerequisite

  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)
  6. At this point the code should be SA 2.0-compatible. Update requirements.txt.
@berggren berggren added the Code Health Code health improvements label Nov 13, 2023
@berggren berggren self-assigned this Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Health Code health improvements
Projects
None yet
Development

No branches or pull requests

1 participant