Migration for auth_user.username field

42 views
Skip to first unread message

Graeme Perrow

unread,
Jul 18, 2017, 10:19:09 AM7/18/17
to Django users
I am responsible for the SQL Anywhere Django driver and I'm trying to add support for Django 1.10. When I create a project and run "python manage.py migrate", it executes a bunch of SQL statements but then fails when altering the auth_user table to extend the username field to 150 characters. The problem is that the username column has a unique index on it, and SQL Anywhere does not allow a column to be altered if there's an index on it. I was hoping there was a feature I could enable in the BaseDatabaseFeatures subclass that tells Django this but I couldn't find one. I seem to be stuck.

Does anyone know of a way I can tell Django to drop the unique index, alter the column, and then re-create the index? Is there some sort of hook that I can use to detect this case and drop / recreate the index myself?

Thanks

Markus Holtermann

unread,
Jul 18, 2017, 11:15:33 AM7/18/17
to Django users
Hi Graeme, the only solution that comes to mind is overriding the alter_field() or _alter_field() methods on the schema editor: https://github.com/django/django/blob/stable/1.11.x/django/db/backends/base/schema.py

/Markus
Reply all
Reply to author
Forward
0 new messages