Search code examples
pythondjangopostgresqldjango-southdjango-models

Migrating a PositiveSmallIntegerField to a PositiveIntegerField and using the BIGINT field in Postgres


One of my models had a field defined a PositiveSmallIntegerField. Upon describing the table, I've seen that it has been defined as an INTEGER.

I'd like to store values of larger range and therefore I've modified my model to use the PositiveIntegerField.

Now when I run South to generate migrations, it says that nothing was changed in the model? I can see my changes clearly but South ignored this. Why?

Will using a PositiveIntegerField use the BIGINT field in Postgres? Does Django support the BIGINT field of Postgres?


Solution

  • You could use django's built-in BigIntegerField instead of PositiveIntegerField.

    If South still ignores this change, you can create an empty migration and add the following to your forwards method:

    db.alter_column('table_name', 'column', self.gf('django.db.models.fields.BigIntegerField'))
    

    Hope it helps :)