我在尝试修复迁移错误时压缩了我的迁移,并产生了第二个错误,我很困惑。
当我尝试迁移我的heroku数据库时,我收到此错误:
$ heroku run -a agorafund python manage.py migrate
Running `python manage.py migrate` attached to terminal... up, run.8709
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__
self.build_graph()
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/loader.py", line 294, in build_graph
_reraise_missing_dependency(migration, parent, e)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/loader.py", line 264, in _reraise_missing_dependency
raise exc
django.db.migrations.graph.NodeNotFoundError: Migration nonprofits.0001_initial dependencies reference nonexistent parent node (u'payments', u'0001_squashed_0026_bankaccount')
最后,它说“初始依赖关系引用不存在的父节点。(u'payments',u'0001_squashed_0026_bankaccount')”
但该节点显然存在。 “0001_squashed_0026_bankaccount”存在于我的payment / migrations文件夹中,并且没有任何循环依赖项。 (它从那开始:)
class Migration(migrations.Migration):
replaces = [('payments', '0001_initial'), ('payments', '0002_auto_20150820_2150'), ('payments', '0003_auto_20150823_1507'), ('payments', '0004_auto_20150823_1832'), ('payments', '0005_auto_20150828_1441'), ('payments', '0006_auto_20150828_1559'), ('payments', '0007_remove_product_fee_rate'), ('payments', '0008_product_fee_rate'), ('payments', '0009_remove_product_fee_rate'), ('payments', '0010_recurringpaymentitem'), ('payments', '0010_auto_20150905_2132'), ('payments', '0011_merge'), ('payments', '0012_auto_20150908_2316'), ('payments', '0013_auto_20150910_1517'), ('payments', '0014_paymentitem_recurring'), ('payments', '0015_subscription'), ('payments', '0016_paymentitem_subscription'), ('payments', '0017_userexternalpayconf_livepayment'), ('payments', '0018_auto_20150916_1852'), ('payments', '0019_auto_20150916_1858'), ('payments', '0020_auto_20150916_2210'), ('payments', '0021_auto_20150917_0314'), ('payments', '0022_auto_20150917_1556'), ('payments', '0023_userexternalpayconf_newcreditcard'), ('payments', '0024_auto_20150917_2004'), ('payments', '0025_subscription_paymentitem'), ('payments', '0026_bankaccount')]
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('auth', '0006_require_contenttypes_0002'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
同时,非营利组织的初始迁移开始如此:
类迁移(migrations.Migration):
dependencies = [
('payments', '0001_squashed_0026_bankaccount'),
]
任何想法发生了什么?
答案 0 :(得分:0)
删除迁移(migrations/
中的所有内容除了__init__.py
当然)为我解决了这个问题。 Stack Overflow回答的建议:
如果找不到丢失的迁移文件,则必须删除 并重新创建应用程序的迁移,以便他们不依赖 失踪的迁移。 https://stackoverflow.com/a/33676462/1762493