Changes between Initial Version and Version 3 of Ticket #28193
- Timestamp:
- May 11, 2017, 5:50:11 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28193
- Property Summary Maximum length of Column in through table is not updated in migrations → Maximum length of database column in many-to-many through table is not updated if the foreign keyed model has a CharField primary key
- Property Keywords manytomanyfield primary key varchar max length added
- Property Type Uncategorized → Bug
-
Ticket #28193 – Description
initial v3 2 2 3 3 Starting with the below minimal example 4 ``` 4 {{{ 5 5 from django.db import models 6 6 … … 13 13 class Bar(models.Model): 14 14 foos = models.ManyToManyField(Foo) 15 ``` 15 }}} 16 16 17 17 Run `./manage.py makemigrations` then `./manage.py migrate`. 18 18 19 19 Change the `max_length` of `Foo.code` to a higher value e.g. 100 20 ``` 20 {{{ 21 21 from django.db import models 22 22 … … 29 29 class Bar(models.Model): 30 30 foos = models.ManyToManyField(Foo) 31 ``` 31 }}} 32 32 Run `./manage.py makemigrations` then `./manage.py migrate` once more. 33 33 34 34 The final `myapp_bar_foos` table DDL is: 35 35 36 ``` 36 {{{ 37 37 CREATE TABLE "myapp_bar_foos" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "bar_id" integer NOT NULL REFERENCES "myapp_bar" ("id"), "foo_id" varchar(15) NOT NULL REFERENCES "myapp_foo" ("code")); 38 38 CREATE UNIQUE INDEX "myapp_bar_foos_bar_id_foo_id_6037806e_uniq" ON "myapp_bar_foos" ("bar_id", "foo_id"); 39 39 CREATE INDEX "myapp_bar_foos_bar_id_f5103189" ON "myapp_bar_foos" ("bar_id"); 40 40 CREATE INDEX "myapp_bar_foos_foo_id_84900b21" ON "myapp_bar_foos" ("foo_id") 41 ``` 41 }}} 42 42 43 43 The `foo_id` column should have been updated to type `varchar(100)` but it remains as `varchar(15)`.