From: Bryan Date: Fri, 10 Jan 2014 09:24:13 +0000 (-0500) Subject: models don't work because they aren't in sync with the migrations; dump the field... X-Git-Tag: release-20150131~282 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0914eb58e6b5d452fddfe070387f41d848d31f67;p=oweals%2Fkarmaworld.git models don't work because they aren't in sync with the migrations; dump the field and recreate it --- diff --git a/karmaworld/apps/notes/migrations/0013_auto__chg_field_note_user.py b/karmaworld/apps/notes/migrations/0013_auto__chg_field_note_user.py index fa418f6..3eb44db 100644 --- a/karmaworld/apps/notes/migrations/0013_auto__chg_field_note_user.py +++ b/karmaworld/apps/notes/migrations/0013_auto__chg_field_note_user.py @@ -3,7 +3,6 @@ import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models -from karmaworld.apps.notes.models import Note class Migration(SchemaMigration): @@ -15,23 +14,23 @@ class Migration(SchemaMigration): def forwards(self, orm): # Dealing with previous FK problem. - # Remove all previous foreign keys which will shortly point at the - # wrong thing. Unrecoverable change. - Note.objects.update(user=None) - # Renaming column for 'Note.user' to match new field type. - db.rename_column('notes_note', 'user', 'user_id') - + # Instead of alter_column, drop and readd the column to remove + # leftover foreign key values. + db.delete_column('notes_note', 'user') # Changing field 'Note.user' - db.alter_column('notes_note', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, on_delete=models.SET_NULL)) + db.add_column('notes_note', 'user', + self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, on_delete=models.SET_NULL, blank=True), + keep_default=False) def backwards(self, orm): # Changing field 'Note.user' - db.alter_column('notes_note', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['users.KarmaUser'], null=True, on_delete=models.SET_NULL)) - # Dealing with previous FK problem. + db.delete_column('notes_note', 'user_id') # Renaming column for 'Note.user' to match new field type. - db.rename_column('notes_note', 'user_id', 'user') + db.add_column('notes_note', 'user', + self.gf('django.db.models.fields.IntegerField')(null=True, blank=True), + keep_default=False) models = { 'auth.group': {