2

I squashed my migrations while trying to fix a migration error, and it produced a second error that I'm confused by.

When I try to migrate my heroku database, I get this error:

$ 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')

At the end there it says "initial dependencies reference nonexistent parent node. (u'payments', u'0001_squashed_0026_bankaccount')"

But that node clearly exist. "0001_squashed_0026_bankaccount" exists in my payments/migrations folder, and it doesn't have any circular dependencies. (It begins thus:)

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),
    ]

Meanwhile the nonprofits initial migration begins like thus:

class Migration(migrations.Migration):

dependencies = [
    ('payments', '0001_squashed_0026_bankaccount'),
]

Any ideas what's going on?

Paulo Pessoa
  • 2,509
  • 19
  • 30
Raemon
  • 411
  • 2
  • 4
  • 7

1 Answers1

0

Deleting the migrations (everything in migrations/ except the __init__.py of course) fixed this for me. A suggestion from this Stack Overflow answer:

If you can't find the missing migration file, you'll have to delete and recreate the migrations for the app, so that they don't depend on the missing migration. https://stackoverflow.com/a/33676462/1762493

Community
  • 1
  • 1
Mikeumus
  • 3,570
  • 9
  • 40
  • 65