Changes between Initial Version and Version 3 of Ticket #28193


Ignore:
Timestamp:
May 11, 2017, 5:50:11 AM (7 years ago)
Author:
James Hiew
Comment:

Fix formatting

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28193

    • Property Summary Maximum length of Column in through table is not updated in migrationsMaximum 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 UncategorizedBug
  • Ticket #28193 – Description

    initial v3  
    22
    33Starting with the below minimal example
    4 ```
     4{{{
    55from django.db import models
    66
     
    1313class Bar(models.Model):
    1414    foos = models.ManyToManyField(Foo)
    15 ```
     15}}}
    1616
    1717Run `./manage.py makemigrations` then `./manage.py migrate`.
    1818
    1919Change the `max_length` of `Foo.code` to a higher value e.g. 100
    20 ```
     20{{{
    2121from django.db import models
    2222
     
    2929class Bar(models.Model):
    3030    foos = models.ManyToManyField(Foo)
    31 ```
     31}}}
    3232Run `./manage.py makemigrations` then `./manage.py migrate` once more.
    3333
    3434The final `myapp_bar_foos` table DDL is:
    3535
    36 ```
     36{{{
    3737CREATE 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"));
    3838CREATE UNIQUE INDEX "myapp_bar_foos_bar_id_foo_id_6037806e_uniq" ON "myapp_bar_foos" ("bar_id", "foo_id");
    3939CREATE INDEX "myapp_bar_foos_bar_id_f5103189" ON "myapp_bar_foos" ("bar_id");
    4040CREATE INDEX "myapp_bar_foos_foo_id_84900b21" ON "myapp_bar_foos" ("foo_id")
    41 ```
     41}}}
    4242
    4343The `foo_id` column should have been updated to type `varchar(100)` but it remains as `varchar(15)`.
Back to Top