在新的 MSSQL 服务器上运行迁移时,出现以下错误

如何解决在新的 MSSQL 服务器上运行迁移时,出现以下错误

  Applying account.0001_initial...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 "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             __init__.py",line 419,in execute_from_command_line
    utility.execute()
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             __init__.py",line 413,in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             base.py",line 354,in run_from_argv
    self.execute(*args,**cmd_options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             base.py",line 398,in execute
    output = self.handle(*args,**options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             base.py",line 89,in wrapped
    res = handle_func(*args,**kwargs)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/                                                                                                             commands/migrate.py",line 244,in handle
    post_migrate_state = executor.migrate(
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex                                                                                                             ecutor.py",line 117,in migrate
    state = self._migrate_all_forwards(state,plan,full_plan,fake=fake,fake_i                                                                                                             nitial=fake_initial)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex                                                                                                             ecutor.py",line 147,in _migrate_all_forwards
    state = self.apply_migration(state,migration,fake_initial=fake_                                                                                                             initial)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/ex                                                                                                             ecutor.py",line 230,in apply_migration
    migration_recorded = True
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/base                                                                                                             /schema.py",line 118,in __exit__
    self.execute(sql)
  File "/usr/local/lib/python3.8/dist-packages/sql_server/pyodbc/schema.py",lin                                                                                                             e 871,in execute
    sql = str(sql)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/ddl_                                                                                                             references.py",line 201,in __str__
    return self.template % self.parts
KeyError: 'include'

这段代码在我的网站处理在线用户的部分有问题,我不知道是什么导致了问题,但是如果我第二次尝试运行迁移,它会说一个名为 account_users 的数据库已经存在.如果您需要任何其他信息,请询问。

编辑 1

from django.contrib import admin
from django.urls import include,path

from account.views import (
    registration,logout_view,login_view,#    account_edit_view,account_view,account_create_barzero_order,print_barzero_order_view,choose_order_type,)
from framework.views import(
    index
)

urlpatterns = [
    path('',index,name='home'),path('register/',registration,name="register"),path('logout/',name="logout"),path('login/',name="login"),#    path('account/edit/',account_edit_view,name="account_edit"),path('account/',name="account"),path('admin/',admin.site.urls),path('account/AddOrder/BarZero',name="create_barzero_order"),path('account/order/<int:order_id>',name="print_barzero_order"),path('account/order/choose',name="choose_order_type")
]

编辑 2

从 urls.py 中删除包含后,因为意识到它没有在任何地方使用,我重新运行迁移并出现此错误...

File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py",line 84,in _execute
  return self.cursor.execute(sql,params)
File "/usr/local/lib/python3.8/dist-packages/sql_server/pyodbc/base.py",line 555,in execute
  return self.cursor.execute(sql,params)
pyodbc.ProgrammingError: ('42000',"[42000] [Microsoft][ODBC Driver 17 for sql Server][sql Server]Column 'Prosthodontist.Customer Number' is not the same data type as referencing column 'account_user.prosthodontist_id' in foreign key 'account_user_prosthodontist_id_8fda3091_fk_Prosthodontist_Customer Number'. (1778) (sqlExecDirectW)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py",in main
    execute_from_command_line(sys.argv)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/__init__.py",in execute_from_command_line
    utility.execute()
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/__init__.py",in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py",**cmd_options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py",**options)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/base.py",**kwargs)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/core/management/commands/migrate.py",in handle
    post_migrate_state = executor.migrate(
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/executor.py",fake_initial=fake_initial)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/migrations/executor.py",in apply_migration
    migration_recorded = True
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/base/schema.py",line 882,in execute
    cursor.execute(sql,params)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py",line 66,in execute
    return self._execute_with_wrappers(sql,params,many=False,executor=self._execute)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py",line 75,in _execute_with_wrappers
    return executor(sql,many,context)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py",in _execute
    return self.cursor.execute(sql,params)
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/utils.py",line 90,in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/cagenix/.local/lib/python3.8/site-packages/django/db/backends/utils.py",params)
  File "/usr/local/lib/python3.8/dist-packages/sql_server/pyodbc/base.py",in execute
    return self.cursor.execute(sql,params)
django.db.utils.ProgrammingError: ('42000',"[42000] [Microsoft][ODBC Driver 17 for sql Server][sql Server]Column 'Prosthodontist.Customer Number' is not the same data type as referencing column 'account_user.prosthodontist_id' in foreign key 'account_user_prosthodontist_id_8fda3091_fk_Prosthodontist_Customer Number'. (1778) (sqlExecDirectW)")

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?