Hi all.
Do you have a project with a slow and complicated migration history?
If so, any chance you could lend a brief hand testing?
This refactors the migration graph algorithm and in principle should make it significantly faster.
(More or less linear vs currently exponential.)
Two questions:
1. Is it correct with very complicated histories?
2. Is it a lot quicker?
To answer this could you profile the following script on your complicated project against the PR vs against master
(or any recent version of Django really)?
Are there any errors with the PR that you don't see otherwise?
What's the speedup, if any?
Thanks for your help!
Kind Regards,
Carlton
The scipt:
=======
All it does is calculate the full forwards and backwards migration plan for
each app in your project. It doesn't apply anything.
Dev environment should be fine. (It's the migrations, not the applied state that's in play.)
As ever, please read it before running it. You can do anything similar if you want.
I used IPython from `django-admin shell`:
%timeit %run ./migration_graph_timing.py
If that doesn't work for you and you want me to make it actually run as a stand-alone, let me know.
----
import sys
from django.db import connection
from django.db.migrations.loader import MigrationLoader
loader = MigrationLoader(connection)
backwards = loader.graph.root_nodes()
forwards = loader.graph.leaf_nodes()
print('Calculating backward plans:')
for root in backwards:
loader = MigrationLoader(connection)
sys.stdout.write('.')
#print(loader.graph.backwards_plan(root))
sys.stdout.write('\n')
print('Calculating forward plans:')
for leaf in forwards:
loader = MigrationLoader(connection)
sys.stdout.write('.')
# print(loader.graph.forwards_plan(leaf))
sys.stdout.write('\nRun Done\n\n')
----