Pycharm强大的功能总是让我很是着迷,比如它的makemigrations 和 migrate。
然而某一次,当我再次敲下这熟悉的命令时,它报错了。。。。
Traceback (most recent call last):
File "H:\PyCharm 2018.1.1\helpers\pycharm\django_manage.py", line 52, in <module>
run_command()
File "H:\PyCharm 2018.1.1\helpers\pycharm\django_manage.py", line 46, in run_command
run_module(manage_file, None, '__main__', True)
File "h:\python36\Lib\runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "h:\python36\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "h:\python36\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "H:/PycharmProjects/untitled\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Administrator\Envs\testvir1\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\Administrator\Envs\testvir1\lib\site-packages\django\core\management\__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Administrator\Envs\testvir1\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Administrator\Envs\testvir1\lib\site-packages\django\core\management\base.py", line 335, in execute
output = self.handle(*args, **options)
File "C:\Users\Administrator\Envs\testvir1\lib\site-packages\django\core\management\commands\migrate.py", line 82, in handle
executor.loader.check_consistent_history(connection)
File "C:\Users\Administrator\Envs\testvir1\lib\site-packages\django\db\migrations\loader.py", line 291, in check_consistent_history
connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'. Process finished with exit code 1
不想看上边的朋友我还截了个大图。
错误是:django.db.migrations.exceptions.InconsistentMigrationHistory
在试了一些其他方法后,我发现了一个最简单最暴力的解决方案:
就是打开Navicat,把所有表删掉之后,再次输入 migrate ,回车,就OK了~~~