-
Notifications
You must be signed in to change notification settings - Fork 50
Description
I started a fresh project with Django 3.1. and the latest django-mssql-backend. Running python manage.py migrate auth fails on the "0008" migration:
Applying auth.0008_alter_user_username_max_length...Traceback (most recent call last): File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main execute_from_command_line(sys.argv)
...
File "/.../lib/python3.6/site-packages/django/db/backends/base/schema.py", line 572, in alter_field
old_db_params, new_db_params, strict)
File "/.../lib/python3.6/site-packages/sql_server/pyodbc/schema.py", line 479, in _alter_field
self.execute(self._create_unique_sql(model, columns=[old_field.column]))
File "/.../lib/python3.6/site-packages/sql_server/pyodbc/schema.py", line 863, in execute
sql = str(sql)
File "/.../venv/lib/python3.6/site-packages/django/db/backends/ddl_references.py", line 200, in __str__
return self.template % self.parts
KeyError: 'deferrable'
While experimenting a little, downgrading to Django 2.2 fixed the issue with the problematic migrations, and after upgrading back to 3.1 I was able to run the remaining migrations (those that are new in Django 3). Digging into the code base the problem seems quite straightforward: the django.db.backends.ddl_references.Statement seems indeed to expect a deferrable keyword argument, and after hacking the source code so that an empty string was given as deferrable, the migrations worked just fine. Unfortunately I'm not familiar with mssql or this library, and can't simply attempt a pull request for this.