aaravam aaravam - 1 year ago 74
MySQL Question

Can't migrate Django app - MySQL throws an OperationalError "Too big scale specified"

I am trying to connect my Django app to a MySQL database. I created the database, and tried migrating the app with

python manage.py migrate
. At this point I get the following error:

django.db.utils.OperationalError: (1425, "Too big scale 100 specified for column 'score'. Maximum is 30.")

I checked that object in
. It looks like this:

class Para(models.Model):
text = models.CharField(max_length=20000)
score = models.DecimalField(max_digits=100, decimal_places=5)

def __unicode__(self):
return self.text[:20]

So I changed the
to 20, ran
and tried migrating again. But I keep getting the same error. I am new to MySQL, and not sure what I am doing wrong.

Any help much appreciated. Thanks!

Answer Source

Changing that to

score = models.DecimalField(max_digits=20, decimal_places=5)

Followed by another makemigrations will not work (as you have already found out) because the previous migration is what your server is choking on. The simplest solution, delete the two most recent migrations (assuming that you have not made any other changes). Then run

./manage.py makemigrations
./manage.py migrate
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download