gpt4 book ai didi

django - 删除数据库后表 'django_migrations' 已存在

转载 作者:行者123 更新时间:2023-12-03 08:50:50 31 4
gpt4 key购买 nike

我最近遇到了数据库问题,所以我决定对它进行核攻击,因为我没有重要的数据。我删除了应用程序目录中的迁移文件夹并删除了数据库。但是现在,当我使用 manage.py migrate 重新创建所有内容时,出现以下错误:

  File "../manage.py", line 21, in <module>
main()
File "../manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/migrate.py", line 234, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 91, in migrate
self.recorder.ensure_schema()
File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/recorder.py", line 69, in ensure_schema
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1050, "Table 'django_migrations' already exists"))

我尝试在删除数据库后并重新创建空数据库后运行此命令。我可以 100% 确定现在那里没有 table 。所以我不知道为什么它认为该表在那里。

最佳答案

解决了我的问题。 MariaDB 在缓存中打开了我的表。我运行了两条语句:FLUSH QUERY CACHE;FLUSH TABLES;。我不确定是哪一个成功了,但我随后能够运行迁移,现在一切都恢复正常了!

关于django - 删除数据库后表 'django_migrations' 已存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59103589/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com