#36652: Django Squashed Migrations Randmonly Passing/Failing Based On Set 
Iteration
Order
--------------------------------+--------------------------------------
     Reporter:  Jayden Kneller  |                     Type:  Bug
       Status:  new             |                Component:  Migrations
      Version:  dev             |                 Severity:  Normal
     Keywords:                  |             Triage Stage:  Unreviewed
    Has patch:  1               |      Needs documentation:  0
  Needs tests:  0               |  Patch needs improvement:  0
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+--------------------------------------
 This could be a duplicate of many other projects, but I've figured out a
 bug fix that may also solve the issues of the other projects.

 I've created a github repo that contains a project with migrations,
 squashed migrations, and a management command.  If someone checks out the
 repo and runs the `showmigrations` management command multiple times, the
 results will pass or fail in a way that appears random.

 https://github.com/arrai-innovations/django-migrationnames

 I've tracked the issue down to the order that a set is iterated over.  If
 that set is turned into a list, without any other code changes, the issue
 shown in this test project stops failing and instead passes 100% of the
 time.  I can't guarrantee it will fix every other users issues with
 circular dependency errors, but it will stop the randomness that is
 happening because of iterating through a set.

 If someone uses the management command I created, called `show_issue`, it
 will create output with a number of files that contain results parsed from
 the patched `MigrationLoader`.  The data comes from
 `loader.graph.node_map`, where the migrations and their children are
 stored.  In essence, there are 8 different possibilities that the
 migrations and children can be figured out as, because of the set.  2 of
 these 8 possibilities pass and the other 6 cause circular dependency
 errors.  The fix changes things to have 1 possibility for the way
 migrations and children are figured out, and it passes.

 The randomness of iterating over the set and having 8 possible
 migration/children setups is what makes things difficult to deal with when
 working with squashed migrations.

 I've written about the management command and how to use it in the
 README.md of the django-migrationnames project.

 The fix is really small, which I have in a fork.  Since it is very small,
 this is the change:

 https://github.com/jayden-
 arrai/django/commit/fceaa5820edfbd7128082e7d199034963ae6cd33
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36652>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070199ca9b8c44-a63766c1-cbb0-4cae-8c3a-bad2d1e132a8-000000%40eu-central-1.amazonses.com.

Reply via email to