-
Notifications
You must be signed in to change notification settings - Fork 11
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
Copy alembic files to scaffolds #349
Comments
@cedrikv We should see how we want to handle this or not. Think you solved some things for the last version of thesaurus. So, maybe this ticket is no longer necessary. |
No proper solution yet, I just created new alembic versions in thesaurus with the updates from atramhasis. |
@Wim-De-Clercq Is this something you can look into? The basic problem is that we have alembic migrations in our base package (atramhasis), but that we sometimes want to add migrations to our implementation package (thesaurus in our case) as well, eg. when we add a new conceptscheme. In this case, when we update to a new version of Atramhasis it has no knowledge of the alembic revisions that were created in the local package. Currently, we're just copy-pasting new alembic migrations and doing manual fixes. But is there a better way? Using alemic branches in some way (https://alembic.sqlalchemy.org/en/latest/branches.html)? Or something completely different? |
I do indeed think the branches could be a solution, yes. I'll have to test it a bit to be sure though. |
I did some testing and the following works:
revision = '5cfd7365fc93'
down_revision = None
depends_on = '3bcf11802900' # this is a revision in atramhasis project
branch_labels = ('thesaurus',) I also added an atramhasis label in atramhasis project. Then in the
And then setting everything up looks like: Everything works fine as of yet, but I do still have an open question that I can't find a solution for, so I asked it in the alembic repo. When that is resolved, all that's left is I must make sure that an upgrade from the current installed revision to this new revision setup works flawlessly for dev/test/prod servers. |
The following (little hacky) code can be used to add a custom depends_on to add a dependency within atramhasis revisions: with context.begin_transaction():
revision_map = context.script.revision_map
revision = revision_map._revision_map['b04fd493106b']
revision.dependencies = '5cfd7365fc93'
revision_map.add_revision(revision, _replace=True)
context.run_migrations() This is code in We don't need it now, but I write it here so that hopefully when someone in the future needs they may see it. |
Right now, thesaurus copies all new revisoins from atramhasis over to its own alembic (manual action) Ideally, I would like to change it so that in alembic.ini we configure this:
Then all revisions from atramhasis will be automatically imported and processed.
There would also be 2 heads present in the It is, imo, by far the cleanest project setup. When atramhasis updates, all new revisions are automatically seen and executed. I can clean up the revisions in thesaurus, and manually insert a row in the
But what about other projects in the world that use atramhasis. We can't just ask them to do a change like this themselves, can we? |
Updated docs with more alembic information. Added a branch label to the first atramhasis revision. Fixes #349
Updated docs with more alembic information. Added a branch label to the first atramhasis revision. Fixes #349
Updated docs with more alembic information. Added a branch label to the first atramhasis revision. Fixes #349
@Wim-De-Clercq We are missing an estimate for this one |
Let's add the alembic files to scaffolds as well. That way, an implementation can maintain it's own alembic migrations. Whenever an Atramhasis update is scaffolded in, the user should create a new merge? Not sure if this will work cleanly.
The text was updated successfully, but these errors were encountered: