X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6ab5e576c0bccd88cc5d4e6924373a5e393b0fa1..59b65a24cec4ac67848293297f3bb1bd6cf99872:/migrations/001_add_book_count_to_shelf.py?ds=sidebyside diff --git a/migrations/001_add_book_count_to_shelf.py b/migrations/001_add_book_count_to_shelf.py deleted file mode 100644 index 4af55a172..000000000 --- a/migrations/001_add_book_count_to_shelf.py +++ /dev/null @@ -1,16 +0,0 @@ -from django.core.management import setup_environ -import settings - -setup_environ(settings) - -from catalogue.models import Tag, Book -from django.db import connection - -query = 'ALTER TABLE catalogue_tag ADD COLUMN book_count integer NOT NULL DEFAULT 0' - -cursor = connection.cursor() -cursor.execute(query) - -for shelf in Tag.objects.filter(category='set'): - shelf.book_count = len(Book.tagged.with_all(shelf)) - shelf.save()