我最近遇到了一个数据库问题,所以我决定删除它,因为我没有重要的数据。我删除了app目录中的迁移文件夹,并删除了数据库。但是,现在当我使用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%确定那里现在没有桌子。所以我不知道为什么它会认为那张表在那里。
发布于 2019-11-29 11:39:42
解决了我的问题。MariaDB在缓存中打开了我的表。我运行了两个语句:FLUSH QUERY CACHE;
和FLUSH TABLES;
。我不确定哪一个成功了,但是我可以运行迁移了,现在一切都正常了!
发布于 2019-12-22 10:39:26
删除迁移并重新创建项目目录和startapp目录。然后进行移民和迁移。在mySQL上工作过。
https://stackoverflow.com/questions/59103589
复制相似问题