dan*_*mer 25 database migration django django-south
我已经在我的项目上使用了South一段时间了,但我最近做了大量的开发并改变了开发机器,我认为在这个过程中搞砸了.该项目工作正常,但我无法应用迁移.每当我尝试应用迁移时,我都会得到以下回溯:
danpalmer:pest Dan$ python manage.py migrate frontend
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/management/commands/migrate.py", line 102, in handle
delete_ghosts = delete_ghosts,
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/migration/__init__.py", line 182, in migrate_app
applied = check_migration_histories(applied, delete_ghosts)
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/migration/__init__.py", line 85, in check_migration_histories
m = h.get_migration()
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/models.py", line 34, in get_migration
return self.get_migrations().migration(self.migration)
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/models.py", line 31, in get_migrations
return Migrations(self.app_name)
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/migration/base.py", line 60, in __call__
self.instances[app_label] = super(MigrationsMetaclass, self).__call__(app_label_to_app_module(app_label), **kwds)
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/migration/base.py", line 88, in __init__
self.set_application(application, force_creation, verbose_creation)
File "/Library/Python/2.6/site-packages/South-0.7-py2.6.egg/south/migration/base.py", line 159, in set_application
raise exceptions.NoMigrations(application)
south.exceptions.NoMigrations: Application '<module 'django.contrib.auth' from '/Library/Python/2.6/site-packages/django/contrib/auth/__init__.pyc'>' has no migrations.
Run Code Online (Sandbox Code Playgroud)
我对南方没有经验,我之前没有遇到过这个错误.我可以在网上找到关于这个错误的唯一有用的提及是对于0.7之前我认为我在南0.7.为了确保我跑'easy_install -U South'.
sjh*_*sjh 43
留在这里为未来的googlers
我最近使用我自己的一个应用程序遇到了这个例外,而不是贡献者.
经过一番搔痒后,我注意到了某种文件......
app/migrations/__init__.py
Run Code Online (Sandbox Code Playgroud)
...已被删除,这意味着python无法将dir作为模块等导入.
dan*_*mer 26
我解决了这个问题.
显然,你不能使用South为Django的应用程序进行迁移,比如'auth',所以我不知道为什么要尝试.
我意识到有一段时间我在我的项目中有另一个名为auth的应用程序.我必须在重命名它之前尝试迁移它,因此搞砸了所有这些.
我从该应用程序的数据库中删除了迁移历史记录条目,一切都很好.
Tom*_*ner 11
我刚刚在分支和应用程序版本之后遇到了这个问题,并决定从south_migrationhistory表中删除现在没有迁移的应用程序
./manage.py dbshell
mysql> SELECT * FROM south_migrationhistory WHERE app_name = 'social_auth';
104 | social_auth | 0001_initial...
105 | social_auth | 0002_auto__add_unique_nonce...
mysql> DELETE FROM south_migrationhistory WHERE app_name = 'social_auth';
Query OK, 2 rows affected (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
我也有同样的问题,最后我通过删除south_migrationhistory表中的所有行并从终端运行以下命令来修复此问题.
python manage.py reset south
Run Code Online (Sandbox Code Playgroud)
这个答案解释了如何重置南迁移历史.
编辑:
从Django 1.5开始reset
命令将无法正常工作.相反,你必须使用flush
.
python manage.py flush
Run Code Online (Sandbox Code Playgroud)
要了解有关flush将执行的操作的更多信息,请阅读此stackoverflow答案.
归档时间: |
|
查看次数: |
11737 次 |
最近记录: |