3 from south.db import db
4 from south.v2 import SchemaMigration
5 from django.db import models
7 class Migration(SchemaMigration):
9 def forwards(self, orm):
10 # Saving data which would be 'Lost In Migration'
13 for book in orm.Book.objects.all():
15 medias.append({"url": book.odt_file.url, "book": book, "type": "odt" })
19 medias.append({"url": book.daisy_file.url, "book": book, "type": "daisy"})
23 medias.append({"url": book.ogg_file.url, "book": book, "type": "ogg" })
27 medias.append({"url": book.mp3_file.url, "book": book, "type": "mp3" })
31 # Adding model 'BookMedia'
32 db.create_table('catalogue_bookmedia', (
33 ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
34 ('type', self.gf('django.db.models.fields.CharField')(max_length='100')),
35 ('name', self.gf('django.db.models.fields.CharField')(max_length='100', blank=True)),
36 ('file', self.gf('django.db.models.fields.files.FileField')(max_length=100, blank=True)),
37 ('uploaded_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
39 db.send_create_signal('catalogue', ['BookMedia'])
41 # Deleting field 'Book.odt_file'
42 db.delete_column('catalogue_book', 'odt_file')
44 # Deleting field 'Book.daisy_file'
45 db.delete_column('catalogue_book', 'daisy_file')
47 # Deleting field 'Book.ogg_file'
48 db.delete_column('catalogue_book', 'ogg_file')
50 # Deleting field 'Book.mp3_file'
51 db.delete_column('catalogue_book', 'mp3_file')
53 # Adding M2M table for field medias on 'Book'
54 db.create_table('catalogue_book_medias', (
55 ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
56 ('book', models.ForeignKey(orm['catalogue.book'], null=False)),
57 ('bookmedia', models.ForeignKey(orm['catalogue.bookmedia'], null=False))
59 db.create_unique('catalogue_book_medias', ['book_id', 'bookmedia_id'])
61 # Changing field 'Tag.main_page'
62 db.alter_column('catalogue_tag', 'main_page', self.gf('django.db.models.fields.BooleanField')(blank=True))
64 # Moving data from previous state to the new one
68 name = media['url'].split("/")[-1].split(".")[1]
70 name = media['url'].split("/")[-1]
71 bookMedia = orm.BookMedia.objects.create(file=media['url'], type=media['type'], name=name)
72 media['book'].medias.add(bookMedia)
74 def backwards(self, orm):
76 # Deleting model 'BookMedia'
77 db.delete_table('catalogue_bookmedia')
79 # Adding field 'Book.odt_file'
80 db.add_column('catalogue_book', 'odt_file', self.gf('django.db.models.fields.files.FileField')(default=None, max_length=100, blank=True), keep_default=False)
82 # Adding field 'Book.daisy_file'
83 db.add_column('catalogue_book', 'daisy_file', self.gf('django.db.models.fields.files.FileField')(default=None, max_length=100, blank=True), keep_default=False)
85 # Adding field 'Book.ogg_file'
86 db.add_column('catalogue_book', 'ogg_file', self.gf('django.db.models.fields.files.FileField')(default=None, max_length=100, blank=True), keep_default=False)
88 # Adding field 'Book.mp3_file'
89 db.add_column('catalogue_book', 'mp3_file', self.gf('django.db.models.fields.files.FileField')(default=None, max_length=100, blank=True), keep_default=False)
91 # Removing M2M table for field medias on 'Book'
92 db.delete_table('catalogue_book_medias')
94 # Changing field 'Tag.main_page'
95 db.alter_column('catalogue_tag', 'main_page', self.gf('django.db.models.fields.BooleanField')())
100 'Meta': {'object_name': 'Group'},
101 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
102 'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'unique': 'True'}),
103 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
106 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
107 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
108 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
109 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
110 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
113 'Meta': {'object_name': 'User'},
114 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
115 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
116 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
117 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
118 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
119 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
120 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
121 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
122 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
123 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
124 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
125 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
126 'username': ('django.db.models.fields.CharField', [], {'max_length': '30', 'unique': 'True'})
129 'Meta': {'object_name': 'Book'},
130 '_short_html': ('django.db.models.fields.TextField', [], {}),
131 '_short_html_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
132 '_short_html_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
133 '_short_html_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
134 '_short_html_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
135 '_short_html_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
136 '_short_html_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
137 '_short_html_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
138 '_short_html_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
139 '_tag_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}),
140 '_theme_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}),
141 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
142 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
143 'epub_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
144 'extra_info': ('catalogue.fields.JSONField', [], {}),
145 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
146 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
147 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
148 'medias': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.BookMedia']", 'symmetrical': 'False'}),
149 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'blank': 'True', 'null': 'True', 'to': "orm['catalogue.Book']"}),
150 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
151 'pdf_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
152 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'unique': 'True', 'db_index': 'True'}),
153 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
154 'txt_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
155 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
156 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'})
158 'catalogue.bookmedia': {
159 'Meta': {'object_name': 'BookMedia'},
160 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
161 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
162 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
163 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
164 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
166 'catalogue.bookstub': {
167 'Meta': {'object_name': 'BookStub'},
168 'author': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
169 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
170 'pd': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
171 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'unique': 'True', 'db_index': 'True'}),
172 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
173 'translator': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
174 'translator_death': ('django.db.models.fields.TextField', [], {'blank': 'True'})
176 'catalogue.filerecord': {
177 'Meta': {'object_name': 'FileRecord'},
178 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
179 'sha1': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
180 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
181 'time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
182 'type': ('django.db.models.fields.CharField', [], {'max_length': '20', 'db_index': 'True'})
184 'catalogue.fragment': {
185 'Meta': {'object_name': 'Fragment'},
186 '_short_html': ('django.db.models.fields.TextField', [], {}),
187 '_short_html_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
188 '_short_html_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
189 '_short_html_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
190 '_short_html_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
191 '_short_html_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
192 '_short_html_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
193 '_short_html_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
194 '_short_html_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
195 'anchor': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
196 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'fragments'", 'to': "orm['catalogue.Book']"}),
197 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
198 'short_text': ('django.db.models.fields.TextField', [], {}),
199 'text': ('django.db.models.fields.TextField', [], {})
202 'Meta': {'unique_together': "(('slug', 'category'),)", 'object_name': 'Tag'},
203 'book_count': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
204 'category': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
205 'death': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
206 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
207 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
208 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
209 'main_page': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
210 'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
211 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
212 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}),
213 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
214 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'})
216 'catalogue.tagrelation': {
217 'Meta': {'unique_together': "(('tag', 'content_type', 'object_id'),)", 'object_name': 'TagRelation', 'db_table': "'catalogue_tag_relation'"},
218 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
219 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
220 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
221 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'to': "orm['catalogue.Tag']"})
223 'contenttypes.contenttype': {
224 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
225 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
226 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
227 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
228 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
232 complete_apps = ['catalogue']