question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migration broken from 0.2.19 (and older)

See original GitHub issue

This is followup for #16.

With #25 the migration from 0.2.20 and 0.2.21 is working fine, however users upgrading from 0.2.19 and older will still end up with error.

It can end up with error described in #16:

KeyError: u"Migration social_django.0002_add_related_name dependencies reference nonexistent parent node (u'social_django', u'0001_initial')"

Or it can pop up as error while validating relations (see https://github.com/WeblateOrg/weblate/issues/1344):

ValueError: The field accounts.VerifiedEmail.social was declared with a lazy reference to 'social_django.usersocialauth', but app 'social_django' isn't installed.

The problem is that Django does not see the old migrations as they are just half applied (due to missing social_auth ones):

manage.py showmigrations
...
social_django
 [ ] 0005_auto_20160727_2333 (1 squashed migrations)
 [ ] 0006_partial
...

This is what is stored in the database:

id app name applied
70 default 0001_initial 2017-02-01 15:03:35.625824
112 default 0002_add_related_name 2017-02-01 15:03:41.684870
113 default 0003_alter_email_max_length 2017-02-01 15:03:41.739056
114 default 0004_auto_20160423_0400 2017-02-01 15:03:41.877357

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

33reactions
rlfrahmcommented, Apr 17, 2017

@coriolinus I had that same issue after hammering (incorrectly) past the issue described in this comment: https://github.com/python-social-auth/social-app-django/issues/22#issuecomment-274850091

Doing the following db stuff got me past that issue.

$ update django_migrations set app='social_django' where app='default';

Ref: https://github.com/python-social-auth/social-app-django/issues/22#issuecomment-274856118

Then I encountered your error @Kuein and did the following:

$ python manage.py migrate social_django 0001 --fake

and then finished the migrations for social_django:

$ python manage.py migrate social_django

Then <span class="emoji-outer emoji-sizer"><span class="emoji-inner" style="background: url(chrome-extension://immhpnclomdloikkpcefncmfgjbkojmh/emoji-data/sheet_apple_64.png);background-position:80% 47.5%;background-size:4100%"></span></span> and <span class="emoji-outer emoji-sizer"><span class="emoji-inner" style="background: url(chrome-extension://immhpnclomdloikkpcefncmfgjbkojmh/emoji-data/sheet_apple_64.png);background-position:12.5% 72.5%;background-size:4100%"></span></span> appeared… and everything works!

8reactions
coriolinuscommented, Feb 16, 2017

I’m encountering the same isssue, and the steps listed in the migrations guide do not help:

$ pip list --format=columns | grep social
python-social-auth        0.2.21
rest-social-auth          0.5.0
social-auth-app-django    1.1.0
social-auth-core          1.2.0
$ ./manage.py showmigrations social_django
social_django
 [ ] 0005_auto_20160727_2333 (1 squashed migrations)
 [ ] 0006_partial
$ ./manage.py migrate social_django
Operations to perform:
  Apply all migrations: social_django
Running migrations:
  Applying social_django.0005_auto_20160727_2333...Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/db/migrations/migration.py", line 119, in apply
    operation.state_forwards(self.app_label, project_state)
  File "/mnt/d/Users/coriolinus/Documents/Toptal/cardamom/.venv_wsl/lib/python3.5/site-packages/django/db/migrations/operations/models.py", line 521, in state_forwards
    model_state = state.models[app_label, self.name_lower]
KeyError: ('social_django', 'association')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade and Migrate to Oracle Database 19c
First, database migration generally involves moving or modifying the user and application data in the database. This means that the size of your...
Read more >
The Great Migration (1910-1970) | National Archives
The Great Migration is often broken into two phases, coinciding with the participation and effects of the United States in both World Wars....
Read more >
Early human migrations - Wikipedia
Early human migrations are the earliest migrations and expansions of archaic and modern humans across continents. They are believed to have begun ...
Read more >
Migrating and Splitting Traffic with the Admin API - Google Cloud
Splitting traffic to two or more versions allows you to conduct A/B testing between your versions and provides control over the pace when...
Read more >
typeorm: CHANGELOG
allow per-migration control over transaction behavior (#9459) (6ba48bd), closes #7087 ... fixed regression introduced in 0.3.8 - broken CLI because of #8917 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found