Opened 5 years ago

Closed 5 years ago

#5413 closed defect (fixed)

Make models on clean database with alembic, not from models.py

Reported by: Jessica Tallon Owned by:
Priority: blocker Milestone: 0.9.0
Component: programming Keywords: database, migrations, alembic
Cc: Christopher Allan Webber, Boris Bobrov Parent Tickets:

Description

Currently, when there is a new database with nothing that has been done, we skip all the sqlalchemy-migrate migrations and just make the models based off models.py, we then run the alembic migrations. This actually causes problems when we start doing structural changes in alembic as they have already been done in models.py so when the alembic migrations run, they error.

One solution could be to skip all the alembic migrations, however, I think a better solution is to not make any models off models.py and instead make the initial alembic migration create all the models in the state they're in right now and use alembic migrations to change them in the future, removing all of the code to construct models from model.py.

Subtickets

Change History (3)

comment:1 Changed 5 years ago by Christopher Allan Webber

I agree we need this, but this is tricky, because we currently don't have a solution for alembic migrations with plugins... see #5424.

comment:2 Changed 5 years ago by Christopher Allan Webber

Alternately, we could put off #5424 (though we shouldn't put it off very long) and only initialize tables for non-plugin stuff.

But I worry a bit about that direction. We might get ourselves into trouble if we procrastinate on solving #5424 and close this issue.

comment:3 Changed 5 years ago by Christopher Allan Webber

Resolution: fixed
Status: newclosed

There we go... it's merged at last! I tested as well as I could and pushed. See the docs... there are a lot of changes to how things work...

Note: See TracTickets for help on using tickets.