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

Replace SQLAlchemy Migrate with Alembic #13513

Merged
merged 54 commits into from
Mar 11, 2022

Commits on Mar 9, 2022

  1. Add alembic to dependencies

    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    e248cbe View commit details
    Browse the repository at this point in the history
  2. Add testing infrastructure

    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    2cbc7f5 View commit details
    Browse the repository at this point in the history
  3. Add alembic infrastructure

    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    94d9a68 View commit details
    Browse the repository at this point in the history
  4. Add alembic dir to ignore list in run_tests

    Otherwise alembic/env.py gets executed out of context at test collection
    stage (via tox -e unit >> run_tests.sh), which raises an AttributeError
    (alembic.context is not set in this case)
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    e8c12ae View commit details
    Browse the repository at this point in the history
  5. Add alembic dir to ignore list in package tests

    Otherwise alembic/env.py gets executed out of context at test collection
    stage (via tox -e unit >> run_tests.sh), which raises an AttributeError
    (alembic.context is not set in this case)
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    3be1f6f View commit details
    Browse the repository at this point in the history
  6. Move engine_options default arg initialization to engine_factory

    To eliminate the repetitive `engine_options = engine_options or {}` in
    multiple places.
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    6f6c778 View commit details
    Browse the repository at this point in the history
  7. Remove migrations test from first starup workflow

    This tests sqlalchemy migrate which is being replaced.
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    ee654c1 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    9b91040 View commit details
    Browse the repository at this point in the history
  9. Run tests under Python 3.7

    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    8dacdac View commit details
    Browse the repository at this point in the history
  10. Move triggers out of migrate directory

    (does not include an import in mapping.py: to be added in a separate
    commit, grouped with other edits in mapping.py)
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    be53ebe View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    e7de070 View commit details
    Browse the repository at this point in the history
  12. Avoid extra trip to db via lazy load of alembic version heads (squashed)

    Squashed:
    - pick 01a42712d2 Avoid extra trip to db via lazy load of alembic version heads
    - squash 8d729974d6 Fix mypy error
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    a9049f8 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    38f9b42 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    58ab658 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    619228e View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    bd5bb85 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    c4fc9f6 View commit details
    Browse the repository at this point in the history
  18. Integrate migrations into config, model (squashed)

    - pick 058f09a Integrate migrations design into config and model code
    - squash 89ca1a537b Drop config.database_create_tables (not used)
    
    Next squash:
    - pick cbf29e138c Integrate migrations into config, model (squashed)
    - squash dd51fd578e Address existing mypy error (see note)
    
    Address existing mypy error (see note)
    
    This is a (possible) bug that has existed on dev. To expose it, simply
    change this call to init_models_from_config
    (https://github.com/galaxyproject/galaxy/blob/release_21.09/lib/galaxy/config/__init__.py#L1302)
    to a call directly to mapping.init(). The result will be 6 mypy errors.
    
    The reason is that the mapping.init() function
    (https://github.com/galaxyproject/galaxy/blob/release_21.09/lib/galaxy/model/mapping.py#L79)
    specifies its return type as GalaxyModelMapping - which results in
    several errors of this type:
    
    lib/galaxy/app.py:178: error: Definition of "model" in base class "MinimalApp" is incompatible with definition in base class "ConfiguresGalaxyMixin"
    
    When we call an intermediary function (that does not have a return type
    specified), mypy is happy.
    
    This should be addressed in a separate issue/PR. Removing the return
    type is the simplest (temporary) solution.
    
    Next squash:
    - squash c842973 Add type hints to migrations modules
    - squash a54be22 Remove circular dependency between migrations and config
    
    Setup infrastructure for running db scripts (squashed)
    
    Squashed:
    - pick 146ff8019a Setup infrastructure for running db scripts
    - squash e0a26dcf3a Move is-one-db check into model.database_utils
    
    Squashed:
    - pick a82c44a Setup infrastructure for running db scripts (squashed)
    - squash 31a1a702fe Fix mypy error
    
    Squashed:
    - pick 14a4eb08e2 Setup infrastructure for running db scripts (squashed)
    - squash b1c6acb0f1 When overriding, override.
    
    Add type hints to migrations modules
    
    Remove circular dependency between migrations and config
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    a961939 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    ad2f223 View commit details
    Browse the repository at this point in the history
  20. Add create/migrate scripts for Alembic dbs (squashed)

    Also add exec permissions to create/migrate python scripts.
    (not sure this is required, adding for consistency with previous
    version)
    
    + A few fixes for TS scripts, tests
    
    Squashed:
    - pick b624432 Add create/migrate scripts for Alembic dbs
    - squash 06f0a92 Fix integration test (test only relevant for TS)
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    3c992a6 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    9db6079 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    5e64233 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    32da859 View commit details
    Browse the repository at this point in the history
  24. Update data package (requirements, packages, includes)

    Note: manage_db entry point needs to be edited in model.orm.scripts.
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    736c6c0 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    609c6b9 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    1bed2da View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    f9bb6dd View commit details
    Browse the repository at this point in the history
  28. Update db index testing: test both models, gxy and tsi

    Also, remove unused env var
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    ee5a345 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    bb4e0fb View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    deb683b View commit details
    Browse the repository at this point in the history
  31. Add migrations README

    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    e265f80 View commit details
    Browse the repository at this point in the history
  32. Add prev. version 180 as new revision.

    Reason: 180 was added in dev, so it was not in 21.09.
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    f87cb9d View commit details
    Browse the repository at this point in the history
  33. Preserve manage_db.sh, but do not hide alembic

    - Preserves usage of legacy script while not hiding the Alembic script.
        (see manage_db.sh and run_alembic.sh)
    - Adds documentation (see top of script files)
    - Includes misc. relevant refactorings
    - Includes unit tests for testing legacy script handling
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    537cf5d View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    337992e View commit details
    Browse the repository at this point in the history
  35. Modify behavior of legacy wrapper, add tests, refactor

    If the database is combined, running `./manage_db.sh upgrade` should upgrade
    BOTH models: gxy and tsi. However, if tsi uses a separate database, only
    the galaxy model should be updated.
    
    Also, see this for context: galaxyproject#13108 (comment)
    
    See inline comments for more details.
    
    The new tests are examples of new behavior.
    
    All refactoring is directly related to the changes in this commit.
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    f32b220 View commit details
    Browse the repository at this point in the history
  36. Check for table existence for vault (see note)

    This was the last revision to the database that was handled with
    SQLAlchemy Migrate prior to the move to Alembic (db version 180).
    However, it was added to the dev branch after 21.09 was released, but
    before 22.01. Therefore, this table should be created when upgrading
    from 21.09, but not from dev.
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    d2f766b View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    6ef54eb View commit details
    Browse the repository at this point in the history
  38. Update manage_db.sh ($@ > "$@")

    Co-authored-by: Dannon <dannon.baker@gmail.com>
    jdavcs and dannon committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    c2b367c View commit details
    Browse the repository at this point in the history
  39. Update manage_db.sh ($@ > "$@")

    Co-authored-by: Dannon <dannon.baker@gmail.com>
    jdavcs and dannon committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    7ee1c47 View commit details
    Browse the repository at this point in the history
  40. Update manage_db.sh (use single = in [ ])

    Co-authored-by: Dannon <dannon.baker@gmail.com>
    jdavcs and dannon committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    3f577e9 View commit details
    Browse the repository at this point in the history
  41. Apply black, isort (squashed)

    Squashed:
    - pick 8a26c3c Fix import order in config
    - squash ebe36de Apply black, isort
    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    92b2e67 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    c8ce9c4 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    3f8a223 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    1a1ae8d View commit details
    Browse the repository at this point in the history
  45. Fix some of the package tests

    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    02437fb View commit details
    Browse the repository at this point in the history
  46. Fix path for package tests

    jdavcs committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    70a7942 View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    6fd1a6e View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    db07621 View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    90d8140 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    67a4fa8 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2022

  1. Configuration menu
    Copy the full SHA
    7535159 View commit details
    Browse the repository at this point in the history
  2. Apply formatting

    jdavcs committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    1421e7a View commit details
    Browse the repository at this point in the history
  3. Drop new migration script (see note)

    This will be added as an alembic revision as a separate commit
    jdavcs committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    84d5787 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2022

  1. Improve error message when SA Migrate version is incorrect

    See inline comment ("version too old" is misleading if the incorrect
    version is more recent than what the system expects).
    jdavcs committed Mar 11, 2022
    Configuration menu
    Copy the full SHA
    44d245f View commit details
    Browse the repository at this point in the history