#26171: ForeignKey with db_constraint=False doesn't generate an index on MySQL
----------------------------+------------------------------------
     Reporter:  jeroenp     |                    Owner:  nobody
         Type:  Bug         |                   Status:  new
    Component:  Migrations  |                  Version:  1.9
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Accepted
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+------------------------------------

Comment (by wdoekes):

 Interestingly we've run into a bug caused on the same spot.

 We run a test case that check whether there are any unmigrated apps. In
 both the non-DB (SimpleTestCase) and SQLite-DB driven and REUSE_DB test it
 succeeds, but in the (newly created) InnoDB case, it claims that a lot of
 foreign key indexes are missing exactly because of this InnoDB exception.

 I wonder why that check is there. Removing the `db_index=False` did not
 seem to have any negative impact, and it causes the weird behaviour to go
 away.

 ----

 The test in question looks basically like this:
 {{{
         loader = ModulesMigrationLoader(our_connection,
 ignore_no_migrations=True)

         # Before anything else, see if there's conflicting apps.
         conflicts = loader.detect_conflicts()
         if conflicts:
             raise Exception('Conflicting migrations detected...')

         # Set up autodetector.
         autodetector = MigrationAutodetector(
             loader.project_state(),
             ProjectState.from_apps(apps),
             # ^-- the patch impacts this to_state, removing incorrect
 db_index=False
         )

         # Detect changes.
         changed = autodetector.changes(graph=loader.graph)

         self.assertFalse(changed, '...')
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26171#comment:2>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.ebdf2284b13e2151ca48de79610b6cb6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to