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 'odt_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
153 'daisy_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
154 'mp3_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
155 'ogg_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
156 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'unique': 'True', 'db_index': 'True'}),
157 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
158 'txt_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
159 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
160 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'})
162 'catalogue.bookmedia': {
163 'Meta': {'object_name': 'BookMedia'},
164 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
165 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
166 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
167 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
168 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
170 'catalogue.bookstub': {
171 'Meta': {'object_name': 'BookStub'},
172 'author': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
173 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
174 'pd': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
175 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'unique': 'True', 'db_index': 'True'}),
176 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
177 'translator': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
178 'translator_death': ('django.db.models.fields.TextField', [], {'blank': 'True'})
180 'catalogue.filerecord': {
181 'Meta': {'object_name': 'FileRecord'},
182 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
183 'sha1': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
184 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
185 'time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
186 'type': ('django.db.models.fields.CharField', [], {'max_length': '20', 'db_index': 'True'})
188 'catalogue.fragment': {
189 'Meta': {'object_name': 'Fragment'},
190 '_short_html': ('django.db.models.fields.TextField', [], {}),
191 '_short_html_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
192 '_short_html_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
193 '_short_html_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
194 '_short_html_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
195 '_short_html_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
196 '_short_html_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
197 '_short_html_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
198 '_short_html_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
199 'anchor': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
200 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'fragments'", 'to': "orm['catalogue.Book']"}),
201 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
202 'short_text': ('django.db.models.fields.TextField', [], {}),
203 'text': ('django.db.models.fields.TextField', [], {})
206 'Meta': {'unique_together': "(('slug', 'category'),)", 'object_name': 'Tag'},
207 'book_count': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
208 'category': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
209 'death': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
210 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
211 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
212 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
213 'main_page': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
214 'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
215 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
216 'sort_key': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
217 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
218 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'})
220 'catalogue.tagrelation': {
221 'Meta': {'unique_together': "(('tag', 'content_type', 'object_id'),)", 'object_name': 'TagRelation', 'db_table': "'catalogue_tag_relation'"},
222 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
223 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
224 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
225 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'to': "orm['catalogue.Tag']"})
227 'contenttypes.contenttype': {
228 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
229 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
230 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
231 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
232 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
236 complete_apps = ['catalogue']