From: Radek Czajka Date: Fri, 5 Aug 2011 07:49:56 +0000 (+0200) Subject: media migrations fix X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/849b853b9daf946df00558e72dd90ab3822b2b1b?ds=sidebyside media migrations fix --- diff --git a/apps/catalogue/migrations/0007_auto__add_field_bookmedia_book.py b/apps/catalogue/migrations/0007_auto__add_field_bookmedia_book.py index 532eaff62..e48ef25dc 100644 --- a/apps/catalogue/migrations/0007_auto__add_field_bookmedia_book.py +++ b/apps/catalogue/migrations/0007_auto__add_field_bookmedia_book.py @@ -9,7 +9,7 @@ class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'BookMedia.book' - db.add_column('catalogue_bookmedia', 'book', self.gf('django.db.models.fields.related.ForeignKey')(default=0, related_name='media', to=orm['catalogue.Book']), keep_default=False) + db.add_column('catalogue_bookmedia', 'book', self.gf('django.db.models.fields.related.ForeignKey')(related_name='media', null=True, to=orm['catalogue.Book']), keep_default=False) def backwards(self, orm): @@ -80,7 +80,7 @@ class Migration(SchemaMigration): }, 'catalogue.bookmedia': { 'Meta': {'ordering': "('type', 'name')", 'object_name': 'BookMedia'}, - 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'to': "orm['catalogue.Book']"}), + 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'null': 'True', 'to': "orm['catalogue.Book']"}), 'extra_info': ('catalogue.fields.JSONField', [], {'default': "'{}'"}), 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), diff --git a/apps/catalogue/migrations/0008_move_media.py b/apps/catalogue/migrations/0008_move_media.py index 163ef40a6..7428dea54 100644 --- a/apps/catalogue/migrations/0008_move_media.py +++ b/apps/catalogue/migrations/0008_move_media.py @@ -82,7 +82,7 @@ class Migration(DataMigration): }, 'catalogue.bookmedia': { 'Meta': {'ordering': "('type', 'name')", 'object_name': 'BookMedia'}, - 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'to': "orm['catalogue.Book']"}), + 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'null': 'True', 'to': "orm['catalogue.Book']"}), 'extra_info': ('catalogue.fields.JSONField', [], {'default': "'{}'"}), 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), diff --git a/apps/catalogue/migrations/0009_auto.py b/apps/catalogue/migrations/0009_auto.py index 315387926..9c8e5c978 100644 --- a/apps/catalogue/migrations/0009_auto.py +++ b/apps/catalogue/migrations/0009_auto.py @@ -11,6 +11,9 @@ class Migration(SchemaMigration): # Removing M2M table for field medias on 'Book' db.delete_table('catalogue_book_medias') + # Changing field 'BookMedia.book' + db.alter_column('catalogue_bookmedia', 'book_id', self.gf('django.db.models.fields.related.ForeignKey')(default=0, to=orm['catalogue.Book'])) + def backwards(self, orm): @@ -22,6 +25,9 @@ class Migration(SchemaMigration): )) db.create_unique('catalogue_book_medias', ['book_id', 'bookmedia_id']) + # Changing field 'BookMedia.book' + db.alter_column('catalogue_bookmedia', 'book_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['catalogue.Book'])) + models = { 'auth.group': {