Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update migrations #224

Merged
merged 2 commits into from
Apr 6, 2015
Merged

Conversation

dustinfarris
Copy link
Contributor

A first stab at aligning migrations with recent versions of Django.

Existing migrations are moved to south_migrations. This means South users will need to be >= 1.0.0 which looks for this directory, or they will have to add to their settings.py:

SOUTH_MIGRATION_MODULES = {
    'oauth2_provider': 'oauth2_provider.south_migrations',
}

I have not extensively tested this on existing projects, but it should be enough to get the conversation started.

Also a great blog post here on supporting new Django migrations in third-party apps: http://treyhunner.com/2014/03/migrating-to-django-1-dot-7/

Note: if you need this right now (for instance if Django is blowing up because you have a custom AUTH_USER model that needs to migrate before oauth2_provider, e.g. if you're seeing things like django.db.utils.ProgrammingError: relation "myapp_user" does not exist when you run your tests), you can replicate the new migrations folder from my fork into your app as something like myapp/oauth2_provider_migrations/ and then add to your settings.py:

MIGRATION_MODULES = {
    'oauth2_provider': 'myapp.oauth2_provider_migrations',
}

Assuming you've been using oauth2_provider for a while, you will need to fake the migration on your regular db so it doesn't complain about the table already being there in the future:

./manage.py migrate --fake oauth2_provider

Move existing migrations to south_migrations and add new
Django-supported migrations in their place.
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.05%) to 96.7% when pulling 5fe4029 on dustinfarris:django-migrations into 59a78c5 on evonove:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.05%) to 96.7% when pulling 5fe4029 on dustinfarris:django-migrations into 59a78c5 on evonove:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.01%) to 96.74% when pulling ab8adc7 on dustinfarris:django-migrations into 59a78c5 on evonove:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.01%) to 96.74% when pulling ab8adc7 on dustinfarris:django-migrations into 59a78c5 on evonove:master.

@jcassee
Copy link

jcassee commented Apr 2, 2015

This change makes django-oauth-toolkit work for my Django 1.7 project. 👍

Thanks @dustinfarris!

@dustinfarris
Copy link
Contributor Author

Be careful if you are simultaneously upgrading to DOT 0.8 as an extra attribute was added without doing a proper migration. (0656670)

You will begin seeing errors, like:

ProgrammingError: column oauth2_provider_application.skip_authorization does not exist

To truly migrate, you will have to:

./manage.py migrate oauth2_provider zero
./manage.py migrate oauth2_provider

This will result in a loss of data.

I am not sure why the maintainers explicitly chose to forego a migration here. See #219. I can potentially update the new migrations for Django >= 1.7 in this PR to accommodate a smoother transition, but I'd like to know more about why the decision was made to skip this particular migration in the first place.

@synasius synasius merged commit ab8adc7 into jazzband:master Apr 6, 2015
@synasius
Copy link
Contributor

synasius commented Apr 6, 2015

Thanks for your work!
Please also read #227.

@dustinfarris
I added south migration for the skip_authorization field here 62847af

@masci masci modified the milestone: 0..8.1 Apr 8, 2015
@alexbw
Copy link

alexbw commented Apr 28, 2015

Without using south migrations, how can we avoid data loss?

@dustinfarris dustinfarris deleted the django-migrations branch May 12, 2015 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants