Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes for initial migration issues #17

Merged
merged 2 commits into from

3 participants

@zerok
Owner

Right now when starting a new project with cab the initial migrations fail due to missing fixtures (like Python as a Language) and missing content types (which are probably created after the initial migrations have been completed).

This patch skips the content migration for Python snippets if no such language is available and also disables the content type migration if the relevant content types don't exist yet.

cab/migrations/0005_populate_version.py
@@ -5,11 +5,16 @@
from django.db import models
from cab.models import VERSION_MAPPING
+import cab.models
@jezdez Owner
jezdez added a note

What's this import for?

@zerok Owner
zerok added a note

Ah, sorry. This was a remnant of testing some other exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@coleifer
Collaborator

Nice! Thanks for looking into this one

@zerok zerok merged commit 8887ade into from
@zerok
Owner

Got no negative feedback about this anymore, so the merge is now complete ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 6, 2012
  1. @zerok
Commits on Feb 8, 2012
  1. @zerok

    Removed uncessary import

    zerok authored
This page is out of date. Refresh to see the latest.
View
6 cab/migrations/0002_migrate_ratings.py
@@ -15,7 +15,11 @@ class Migration(DataMigration):
def forwards(self, orm):
signals.post_save.disconnect(sender=RatedItem, dispatch_uid='update_rating_score')
- ctype = ContentType.objects.get(app_label='cab', model='snippet')
+ try:
+ ctype = ContentType.objects.get(app_label='cab', model='snippet')
+ except ContentType.DoesNotExist, _:
+ # If the content type doesn't even exist yet, this is probably a fresh installation
+ return
for rating in orm['cab.rating'].objects.all():
RatedItem.objects.create(
View
6 cab/migrations/0005_populate_version.py
@@ -9,7 +9,11 @@
class Migration(DataMigration):
def forwards(self, orm):
- python = orm['cab.language'].objects.get(name='Python')
+ python = None
+ try:
+ python = orm['cab.language'].objects.get(name='Python')
+ except models.ObjectDoesNotExist, _:
+ return
for snippet in orm['cab.snippet'].objects.all():
if snippet.language != python:
Something went wrong with that request. Please try again.