X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1615c0eec40aa73f7662469eaeb082ac14477d11..a8828a545c78f34a9b5bfaff8905eccc8985ff23:/apps/catalogue/migrations/0006_epub_tag_counters_and_ltags_descendants.py diff --git a/apps/catalogue/migrations/0006_epub_tag_counters_and_ltags_descendants.py b/apps/catalogue/migrations/0006_epub_tag_counters_and_ltags_descendants.py index dd2e6a2ff..b990fc33f 100644 --- a/apps/catalogue/migrations/0006_epub_tag_counters_and_ltags_descendants.py +++ b/apps/catalogue/migrations/0006_epub_tag_counters_and_ltags_descendants.py @@ -14,13 +14,13 @@ def get_ltag(book, orm): class Migration(SchemaMigration): - + def forwards(self, orm): """ Add _tag_counter and make sure all books carry their ancestors' l-tags """ # Adding fields - db.add_column('catalogue_book', '_tag_counter', self.gf('catalogue.fields.JSONField')(default=''), keep_default=False) - db.add_column('catalogue_book', '_theme_counter', self.gf('catalogue.fields.JSONField')(default=''), keep_default=False) + db.add_column('catalogue_book', '_tag_counter', self.gf('catalogue.fields.JSONField')(null=True)) + db.add_column('catalogue_book', '_theme_counter', self.gf('catalogue.fields.JSONField')(null=True)) db.add_column('catalogue_book', 'epub_file', self.gf('django.db.models.fields.files.FileField')(default='', max_length=100, blank=True), keep_default=False) def ltag_descendants(book, ltags=None): @@ -32,7 +32,7 @@ class Migration(SchemaMigration): ltag = get_ltag(book, orm) for child in book.children.all(): ltag_descendants(child, ltags + [ltag]) - + if not db.dry_run: try: book_ct = orm['contenttypes.contenttype'].objects.get(app_label='catalogue', model='book') @@ -42,8 +42,8 @@ class Migration(SchemaMigration): orm.TagRelation.objects.filter(content_type=book_ct, tag__category='book').delete() for book in orm.Book.objects.filter(parent=None): ltag_descendants(book) - - + + def backwards(self, orm): """ Delete _tag_counter and make sure books carry own l-tag. """ @@ -61,8 +61,8 @@ class Migration(SchemaMigration): orm.TagRelation.objects.filter(content_type=book_ct, tag__category='book').delete() for book in orm.Book.objects.filter(parent=None): orm.TagRelation(object_id=book.pk, tag=get_ltag(book, orm), content_type=book_ct).save() - - + + models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -104,8 +104,8 @@ class Migration(SchemaMigration): '_short_html_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), '_short_html_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), '_short_html_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), - '_tag_counter': ('catalogue.fields.JSONField', [], {'default': "''"}), - '_theme_counter': ('catalogue.fields.JSONField', [], {'default': "''"}), + '_tag_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}), + '_theme_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}), 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'epub_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), @@ -182,5 +182,5 @@ class Migration(SchemaMigration): 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) } } - + complete_apps = ['catalogue']