Best way to change pk field type

105 views
Skip to first unread message

indymike

unread,
Oct 7, 2010, 4:16:04 PM10/7/10
to Django users
Here's my issue - I'm going to run out of integers for my primary key
in one of my tables. I'm using MySQL, which has been absolutely
fantastic, and will for at least a few more decades if I can make a
change from INT to BIGINT.

What's the right way to switch from INT to BIGINT so the PK works
correctly?

/ First thought was a big, fat south migration, but I I wonder if
there's anything in Django's code that this will break?

Scott Gould

unread,
Oct 11, 2010, 8:22:27 AM10/11/10
to Django users
With a huge whopping disclaimer that I've never done this before:

Wouldn't you simply be abe to add an explicit "id =
BigIntegerField(primary_key=True)" to the model and change the column
type accordingly in mysql?

derek

unread,
Oct 11, 2010, 8:25:27 AM10/11/10
to Django users
Found this:
http://stackoverflow.com/questions/283724/big-integer-field-in-django-models
which implies it should "just work" from version 1.2 onwards.

Be aware that Django's sync method wil create the PK field with a
default of int(11), not bigint, so you'll need to change that in the
database itself.
Reply all
Reply to author
Forward
0 new messages