MicroPyramid/django-mfa

1170, "BLOB/TEXT column 'public_key' used in key specification without a key length"

nathanle opened this issue · 5 comments

django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'public_key' used in key specification without a key length")

in ./lib/python3.6/site-packages/django_mfa/migrations/0001_initial.py"

            ('public_key', models.TextField(unique=True)),

What should it be for MySQL?

I got this on a new install of django-mfa after doing a migrate.
Django 2.2.11 with MySQL

It's not a pretty fix but you can get it working by doing the following:

  • Change the django_mfa/migrations/0001_initial.py migration section:
    ('public_key', models.CharField(unique=True, max_length=1024)),
  • Change the same field in the django_mfa/models.py file:
    public_key = models.CharField(unique=True, max_length=1024)

You will be able to migrate now and the app should work normally.

I had the same problem but managed to use it this way.

When I used @icarovirtual's suggestion (thanks for that, by the way) I get this error:

django_mfa.U2FKey.public_key: (mysql.E001) MySQL does not allow unique CharFields to have a max_length > 255

My fix was to leave the public key as none-unique.
Eg

public_key = models.TextField()

in both models.py and migrations/0001_initial.py

@abhijeet-1110 Could you please close this issue? It's solved.