Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django NodeNotFoundError during migration

The error I get when I try to runserver for my django app is as follows:

django.db.migrations.graph.NodeNotFoundError: Migration tasks.0001_initial dependencies reference nonexistent parent node (u'auth', u'0007_alter_validators_add_error_messages')

This happened after I followed this heroku tutorial: https://devcenter.heroku.com/articles/getting-started-with-django

I modified the settings file to include:

import dj_database_url
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

#DATABASES['default'] =  dj_database_url.config()
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'tasks/static'),
)

My 0001_initial migration is as follows:

from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('auth', '0007_alter_validators_add_error_messages'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

I'm lost as to what I should try next to fix this error. Advice appreciated! Thank you!

like image 576
kuthue Avatar asked Jul 07 '15 23:07

kuthue


People also ask

Does Django handle migrations?

Django can't automatically generate data migrations for you, as it does with schema migrations, but it's not very hard to write them. Migration files in Django are made up of Operations, and the main operation you use for data migrations is RunPython .

Should I ignore migrations in Django?

There is only one file in migration folder that you should not ignore. That file is init.py file, If you ignore it, python will no longer look for submodules inside the directory, so any attempts to import the modules will fail.

Is it safe to delete migrations Django?

Deleting migration files means losing your history. This historical info is recorded in the django_migrations table in your database. if you delete migration files, you will get dependency errors. So Don't try to lose your history by deleting your migration files.


1 Answers

your migration has a dependency on a migration in another app () which apparently doesn't exist. if you've removed or moved/consolidation migrations in the 'auth' app, this is possibly why. if you remove the offending migration from this migration, just make sure changes from the '0007' migration in the auth package (check your source code revision history) have already been applied to your current database and you should be fine to continue without that explicit migration. i would also consider checking if any other apps in your project depend on those missing migrations from 'auth'. cheers.

(u'auth', u'0007_alter_validators_add_error_messages')
like image 119
matias elgart Avatar answered Oct 13 '22 14:10

matias elgart