Skip to content

Conversation

@Creylay
Copy link
Collaborator

@Creylay Creylay commented Nov 20, 2025

Summary

This PR redo the migrations configuration that were first applied here: #303 and reverted here: #329

This PR (re)introduce database migration using alembic (automatic migrations). The main objective is to be able to update the database without deleting the current one. Migrations scripts are generated using alembic at dev command and are applied automatically at app startup.

Two main features of this PR is that migrations are applied automatically on app startup and adds CI configuration to check database consistency between models and migrations scripts (to ensure there is no db drift).

Note (previous bug of #303)

It was reported that migrations weren't being applied in the packaged version of DashAI. i.e: after installing it with pip install .. This was caused because alembic configuration wasn't packaged and couldn't be load properly. This is fixed in this PR.


Type of Change

Check all that apply like this [x]:

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

  • Update README.rst with alembic / migration instructions
  • Update alembic configuration to run db migrations. Move alembic config files to DashAI/alembic
  • Update MANIFEST.in to package alembic files.
  • Reset migrations (delete old ones and create an initial one)
  • Runs migrations at app startup. On DashAI/back/app.py
  • Adds CI configuration to check consitency between models and migrations. This will ensure that all PR's that try to merge to develop ensures that migrations are in order (if they modify database.py then they should create the correspondent migration file).

Testing (optional)

No tests added in testing/ but a new CI configuration is added to check drift between migrations and models.

Tested running with:

python -m DashAI

And after

pip install .

dashahi

And migrations were applied correctly on startup.

This way they are packaged and installed properly with the package installation.

Also modify MANIFEST.in to include the alembic files in the sdist package.

Deletes all current migrations as they will be recreated from scratch after this change.
Now we use importlib resources to get the correct path to the alembic folder,
which should work in any environment (and also when packaged).
This checks that there is no database drift between models file and migrations
Alembic config is load programatically, directly read from migrate.py instead of alembic.ini
@Creylay Creylay added enhancement New feature or request back Backend work labels Dec 24, 2025
@Creylay Creylay requested review from cristian-tamblay and removed request for cristian-tamblay December 24, 2025 15:50
Irozuku and others added 22 commits January 7, 2026 10:32
…odel inheritance and adding prepare_output method
@Creylay Creylay requested review from cristian-tamblay and removed request for cristian-tamblay January 7, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

back Backend work enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants