Is there a recommended way to allow "known" differences? #1095
Unanswered
mgaitan
asked this question in
Usage Questions
Replies: 1 comment
-
you can do it that way but it seems more difficult than just omitting those items that you dont want considered. The include_object hook is the main hook for just indicating "skip all of these tables / columns / schemas", which is what it sounds like you are doing. include_name may also be used, which might be better when telling it to skip entire schemas to be ignored. the section https://alembic.sqlalchemy.org/en/latest/autogenerate.html#autogenerate-include-hooks has a good rundown over how to omit elements from the DB side as well as the model from the autogenerate process. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I work with a system that has many differences between the database schema and what the models declare. One of the reasons is that the database comes from a legacy system and the models are not 100% representative of the definition of its tables and, on the other hand, the migrations (which fortunately are sporadic) so far are done manually and can introduce small divergences.
A typical example is an index that exists in the base but is not in the model, then Alembic proposes an upgrade with a drop_index operation.
Now we want to start improving and implementing alembic to autogenerate the migrations, but given the situation we need to accept a "0 point" of known differences that should be ignored for the time being, and then gradually correct what is necessary so that the differences do not exist.
I started to explore an approach based on
process_revision_directives
. From an initial migration, I generate a file "know_diff.json" with the code of every detected operation. Then any migration should keep only the operations that are not in that file.Something like this
So, can it be a valid way or is there a correct / better / official way to do what I want?
Beta Was this translation helpful? Give feedback.
All reactions