Use alembic instead of sqlalchemy-migrate for migrations#3674
Open
jcristau wants to merge 1 commit intomozilla-releng:mainfrom
Open
Use alembic instead of sqlalchemy-migrate for migrations#3674jcristau wants to merge 1 commit intomozilla-releng:mainfrom
jcristau wants to merge 1 commit intomozilla-releng:mainfrom
Conversation
034a867 to
a245c1d
Compare
Existing databases are assumed to have all existing migrations applied. On upgrade, we'll detect the presence of the `migrate_version` table, and set the alembic version to the initial/current schema, `0001`. Also remove the setuptools pin since it was there for sqlalchemy-migrate's benefit.
bhearsum
reviewed
Mar 2, 2026
Contributor
bhearsum
left a comment
There was a problem hiding this comment.
Have you been able to run uv run alembic without issue locally? Any invocation I've tried ends up with an error. For example:
~/repos/balrog ❯ uv run alembic check
Built balrog @ file:///home/bhearsum/repos/balrog
Uninstalled 1 package in 0.77ms
Installed 1 package in 1ms
Traceback (most recent call last):
File "/home/bhearsum/repos/balrog/.venv/bin/alembic", line 10, in <module>
sys.exit(main())
~~~~^^
File "/home/bhearsum/repos/balrog/.venv/lib/python3.13/site-packages/alembic/config.py", line 1047, in main
CommandLine(prog=prog).main(argv=argv)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/home/bhearsum/repos/balrog/.venv/lib/python3.13/site-packages/alembic/config.py", line 1037, in main
self.run_cmd(cfg, options)
~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/home/bhearsum/repos/balrog/.venv/lib/python3.13/site-packages/alembic/config.py", line 971, in run_cmd
fn(
~~^
config,
^^^^^^^
*[getattr(options, k, None) for k in positional],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**{k: getattr(options, k, None) for k in kwarg},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/bhearsum/repos/balrog/.venv/lib/python3.13/site-packages/alembic/command.py", line 363, in check
script_directory.run_env()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/home/bhearsum/repos/balrog/.venv/lib/python3.13/site-packages/alembic/script/base.py", line 545, in run_env
util.load_python_file(self.dir, "env.py")
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/home/bhearsum/repos/balrog/.venv/lib/python3.13/site-packages/alembic/util/pyfiles.py", line 116, in load_python_file
module = load_module_py(module_id, path)
File "/home/bhearsum/repos/balrog/.venv/lib/python3.13/site-packages/alembic/util/pyfiles.py", line 136, in load_module_py
spec.loader.exec_module(module) # type: ignore
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 1023, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/home/bhearsum/repos/balrog/src/auslib/alembic/env.py", line 21, in <module>
fileConfig(config.config_file_name, disable_existing_loggers=False)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/logging/config.py", line 66, in fileConfig
raise FileNotFoundError(f"{fname} doesn't exist")
FileNotFoundError: alembic.ini doesn't exist
Should this work? Or are we content to only interact with it through the API calls in db.py?
Contributor
Author
|
With this in alembic.ini: [alembic]
script_location = src/auslib/alembic
sqlalchemy.url = mysql://balrogadmin:balrogadmin@127.0.0.1/balrog
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARNING
handlers = console
qualname =
[logger_sqlalchemy]
level = WARNING
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%SI can run alembic check against the database set up by the docker-compose config (the logging config above is from the template, I only touched the alembic section). |
Contributor
|
I guess my question was more whether or not this should work out of box. |
Contributor
Author
|
Fair. I don't know TBH... |
Contributor
|
I guess seeing as we don't have that CLI for migration already, we probably don't need it for alembic, at least initially. |
bhearsum
approved these changes
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Existing databases are assumed to have all existing migrations applied.
On upgrade, we'll detect the presence of the
migrate_versiontable, and set the alembic version to the initial/current schema,0001.Also remove the setuptools pin since it was there for sqlalchemy-migrate's benefit.