#34881: migrate crashes when renaming model referenced twice by
ManyToManyField.through model on SQLite.
----------------------------+------------------------------------
     Reporter:  dennisvang  |                    Owner:  nobody
         Type:  Bug         |                   Status:  new
    Component:  Migrations  |                  Version:  dev
     Severity:  Normal      |               Resolution:
     Keywords:  sqlite      |             Triage Stage:  Accepted
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+------------------------------------

Comment (by dennisvang):

 Replying to [comment:10 Natalia Bidart]:
 > Assuming a simpler model for `Person` where the M2M is implicit, and
 doing the rename, does indeed work. The SQL for the migration is:
 > * 0003 (renamed `SimplerPerson` to `SimplerPersonFoo`)
 > {{{#!sql
 >
 > BEGIN;
 > --
 > -- Rename model SimplerPerson to SimplerPersonFoo
 > --
 > ALTER TABLE "ticket_34881_simplerperson" RENAME TO
 "ticket_34881_simplerpersonfoo";
 > CREATE TABLE "ticket_34881_simplerpersonfoo_parents_or_children" ("id"
 integer NOT NULL PRIMARY KEY AUTOINCREMENT, "from_simplerpersonfoo_id"
 bigint NOT NULL REFERENCES "ticket_34881_simplerpersonfoo" ("id")
 DEFERRABLE INITIALLY DEFERRED, "to_simplerpersonfoo_id" bigint NOT NULL
 REFERENCES "ticket_34881_simplerpersonfoo" ("id") DEFERRABLE INITIALLY
 DEFERRED);
 > INSERT INTO "ticket_34881_simplerpersonfoo_parents_or_children" (id,
 from_simplerpersonfoo_id, to_simplerpersonfoo_id) SELECT id,
 from_simplerperson_id, to_simplerperson_id FROM
 "ticket_34881_simplerperson_parents_or_children";
 > DROP TABLE "ticket_34881_simplerperson_parents_or_children";
 > CREATE UNIQUE INDEX
 
"ticket_34881_simplerpersonfoo_parents_or_children_from_simplerpersonfoo_id_to_simplerpersonfoo_id_f05f0b12_uniq"
 ON "ticket_34881_simplerpersonfoo_parents_or_children"
 ("from_simplerpersonfoo_id", "to_simplerpersonfoo_id");
 > CREATE INDEX
 
"ticket_34881_simplerpersonfoo_parents_or_children_from_simplerpersonfoo_id_6d3cdfb4"
 ON "ticket_34881_simplerpersonfoo_parents_or_children"
 ("from_simplerpersonfoo_id");
 > CREATE INDEX
 
"ticket_34881_simplerpersonfoo_parents_or_children_to_simplerpersonfoo_id_83aff647"
 ON "ticket_34881_simplerpersonfoo_parents_or_children"
 ("to_simplerpersonfoo_id");
 > COMMIT;
 > }}}
 >
 > It's worth noting that the content of the explicit M2M (`Relation`) has
 these rows:
 > {{{
 > sqlite> SELECT * FROM ticket_34881_relation;
 > 1|1|3
 > 2|2|3
 > 3|1|4
 > 4|2|4
 > }}}
 >
 > While the rows for the implicit one include:
 > {{{
 > sqlite> SELECT * FROM ticket_34881_simplerperson_parents_or_children;
 > 1|3|1
 > 2|3|2
 > 3|1|3
 > 4|2|3
 > 5|4|1
 > 6|4|2
 > 7|1|4
 > 8|2|4
 > }}}
 >
 >
 > It may look like a valid issue but I'll cc Simon and Mariusz for a
 second opinion.

 Thanks for reproducing this. :-)

 You are right, for the implicit M2M relation, I should have set
 `symmetrical=False` in order to get the equivalent of my explicit
 `Relation`.

 However, the rename also works fine for the implicit case with
 `symmetrical=False`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34881#comment:12>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ae207c497-8059ff2e-a20d-4aed-987b-f64ac45aaa28-000000%40eu-central-1.amazonses.com.

Reply via email to