Skip to content

Can't apply migrations on dev image #418

@rodolfo-r-a-da-silva

Description

@rodolfo-r-a-da-silva

Hello,

I get the following when running the dev image with Docker for the first time:

docker compose -f docker/docker-compose-dev.yml up --build
[...]
goosebit-dev           | INFO:     Will watch for changes in these directories: ['/src']
goosebit-dev           | INFO:     Uvicorn running on http://0.0.0.0:60053 (Press CTRL+C to quit)
goosebit-dev           | INFO:     Started reloader process [1] using StatReload
goosebit-dev           | 2026-03-24 18:49:33,577 - goosebit.plugins - INFO - Checking for plugins to be loaded...
goosebit-dev           | 2026-03-24 18:49:33,577 - goosebit.plugins - INFO - No plugins found.
goosebit-postgres-dev  | 2026-03-24 18:49:33.679 UTC [33] ERROR:  relation "device" does not exist at character 193
goosebit-postgres-dev  | 2026-03-24 18:49:33.679 UTC [33] STATEMENT:  SELECT "sw_version","last_state","last_ipv6","auth_token","last_ip","assigned_software_id","force_update","name","last_seen","last_log","update_mode","hardware_id","id","feed","progress" FROM "device" LIMIT $1
goosebit-dev           | 2026-03-24 18:49:33,684 - goosebit - ERROR - DB does not exist, try running `poetry run aerich upgrade`.
goosebit-dev           | NoneType: None

And when trying to apply the database migration I get the following:

docker exec goosebit-dev python -m aerich upgrade
[...]
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.13/site-packages/aerich/__main__.py", line 3, in <module>
    main()
    ~~~~^^
  File "/usr/local/lib/python3.13/site-packages/aerich/cli.py", line 422, in main
    cli()
    ~~~^^
  File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1550, in __call__
    return anyio.run(self._main, main, args, kwargs, **opts)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/anyio/_core/_eventloop.py", line 77, in run
    return async_backend.run(func, args, {}, backend_options)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2358, in run
    return runner.run(wrapper())
           ~~~~~~~~~~^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2341, in wrapper
    return await func(*args)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1568, in _main
    return await main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1443, in main
    rv = await self.invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1953, in invoke
    await super().invoke(ctx)
  File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1306, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 873, in invoke
    rv = await rv
         ^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aerich/cli.py", line 93, in cli
    await command.init(offline="--offline" in sys.argv)
  File "/usr/local/lib/python3.13/site-packages/aerich/__init__.py", line 92, in init
    await Migrate.init(self.tortoise_config, self.app, self.location, offline=offline)
  File "/usr/local/lib/python3.13/site-packages/aerich/migrate.py", line 172, in init
    raise RuntimeError(
        "Old format of migration file detected, run `aerich fix-migrations` to upgrade format"
    )
RuntimeError: Old format of migration file detected, run `aerich fix-migrations` to upgrade format

And when trying to fix migrations:

docker exec goosebit-dev python -m aerich fix-migrations

2026-03-24 19:13:35,996 - goosebit.plugins - INFO - Checking for plugins to be loaded...
2026-03-24 19:13:35,996 - goosebit.plugins - INFO - No plugins found.
⚠️ Warning: Aerich table not found. fix-migrations can only be applied by using existing database with all migrations applied.

I noticed that there was the release of aerich 0.9.2 since the last time I tried to initialize a goosebit database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions