-
Notifications
You must be signed in to change notification settings - Fork 7
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
Squash migrations #1532
Comments
So, I've given this a try and it's looking like the actual For example: the The migration docs say:
I did try to "break out one of the foreignkeys in the circular dependency loop" but (a) the docs don't really say what this means specifically, so I sort of assumed they mean to delete the foreign key, then squash the migration, then re-add it, this actually seemed to create more problems. Maybe I'm doing it wrong, though? Another technique I found on stack overflow gave a more advanced version of this involving replacing any foreign keys with IntegerFields, sqashing, and then reinstating the foreign keys. I tried this on the "blog" app, which appeared to have only 3 relationships to "common". This succeeded in creating the single squashed migration but did not seem to resolve the circular dependency error. I suspect this is because "common" has foreign keys that point in the other direction. At this point, I sort of decided it might be easier to remove all migrations and re-run
So, in conclusion, I don't really know how much time we want to devote to this, but also some of this might be my lack of familiarity with the best practices. |
Ugh, maybe it's best not to deal with this mess and just let it be as is, but the cruft bugs me as does the startup time (I want it to be cheap to throw away a dev db and start over) so let's spin this out a little further. Let's say we go with the simpler option you reached at the end:
|
I'll collect some data on startup times. |
So, I timed the
In conclusion, it does seem like we can gain ~50% on db-initialization time using a method something like this. |
It looks like we can simplify this method down to:
This seems to work for me, locally, which brings the new migration state into line with the re-created migration files without having to edit the |
This is not urgent, but let's kick this to the backlog and keep the ticket around so we don't lose the research. |
I'm noticing that spinning up a db from scratch is pretty slow. Let's create squash migrations for our apps.
While doing so, double-check if there's any
RunPython
/RunSQL
commands that haven't been elided that can be.The text was updated successfully, but these errors were encountered: