Reputation: 9850
I'm getting an integer out of range
error when trying to migrate my database from SQLite to PostgreSQL.
I think I have pinpointed the problem: I have some huge integers in a IntegerField
field in my model.
Basically on the order of 52675215334.
When I change this value to a small number like 1 and then try to migrate my database, all is fine.
Is there some other data type I should be using other than IntegerField to store these large values?
Upvotes: 22
Views: 35922
Reputation: 11
Do not forget to migrate the changes you did, otherwise it will not work
python manage.py migrate
python manage.py makemigrations
Upvotes: 1
Reputation: 1790
Try this
Change models.IntegerField() to models.BigIntegerField()
class TableName(models.Model):
ColumnName= models.BigIntegerField(default=0)
Upvotes: 1
Reputation: 236150
Try using BigIntegerField if you integers are that big. From the documentation:
A 64 bit integer, much like an IntegerField except that it is guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807. The admin represents this as an
<input type="text">
(a single-line input).
Upvotes: 35