0

请,需要帮助;我使用 django 3.1 的最新版本,使用 django-mssql-backend 迁移 ms sql 数据库,当我尝试迁移时遇到了这个问题:auth.0008_alter_user_username_max_length...Traceback(最近一次调用最后);

   Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  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 "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\core\management\base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\core\management\commands\migrate.py", line 245, in handle
    fake_initial=fake_initial,
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\db\migrations\executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\db\migrations\operations\fields.py", line 236, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\db\backends\base\schema.py", line 572, in alter_field
    old_db_params, new_db_params, strict)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\sql_server\pyodbc\schema.py", line 479, in _alter_field
    self.execute(self._create_unique_sql(model, columns=[old_field.column]))
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\sql_server\pyodbc\schema.py", line 861, in execute
    sql = str(sql)
  File "C:\Users\Leo\PycharmProjects\Django\untitled\venv\lib\site-packages\django\db\backends\ddl_references.py", line 200, in __str__
    return self.template % self.parts
KeyError: 'deferrable'
4

1 回答 1

2

我知道这不是解决办法。但我之前也遇到过类似的问题。为了解决这个问题,我回滚到 Django 3.0.x,然后运行迁移。

希望这对你也有帮助:)

于 2020-08-07T12:43:21.403 回答