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 # Adding model 'BookMedia'
11 db.create_table('catalogue_bookmedia', (
12 ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
13 ('type', self.gf('django.db.models.fields.CharField')(max_length='100')),
14 ('name', self.gf('django.db.models.fields.CharField')(max_length='100')),
15 ('file', self.gf('django.db.models.fields.files.FileField')(max_length=100, blank=True)),
16 ('uploaded_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
18 db.send_create_signal('catalogue', ['BookMedia'])
20 # Saving data which would be 'Lost In Migration'
23 for book in orm.Book.objects.all():
24 medias.append({"url": book.odt_file, "book": book, "type": "odt" })
25 medias.append({"url": book.daisy_file, "book": book, "type": "daisy"})
26 medias.append({"url": book.ogg_file, "book": book, "type": "ogg" })
27 medias.append({"url": book.mp3_file, "book": book, "type": "mp3" })
29 # Deleting field 'Book.odt_file'
30 db.delete_column('catalogue_book', 'odt_file')
32 # Deleting field 'Book.daisy_file'
33 db.delete_column('catalogue_book', 'daisy_file')
35 # Deleting field 'Book.ogg_file'
36 db.delete_column('catalogue_book', 'ogg_file')
38 # Deleting field 'Book.mp3_file'
39 db.delete_column('catalogue_book', 'mp3_file')
41 # Adding M2M table for field medias on 'Book'
42 db.create_table('catalogue_book_medias', (
43 ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
44 ('book', models.ForeignKey(orm['catalogue.book'], null=False)),
45 ('bookmedia', models.ForeignKey(orm['catalogue.bookmedia'], null=False))
47 db.create_unique('catalogue_book_medias', ['book_id', 'bookmedia_id'])
49 # Changing field 'Tag.main_page'
50 db.alter_column('catalogue_tag', 'main_page', self.gf('django.db.models.fields.BooleanField')(blank=True))
52 # Moving data from previous state to the new one
56 name = media['url'].split("/")[-1].split(".")[1]
58 name = media['url'].split("/")[-1]
59 bookMedia = orm.BookMedia.objects.create(file=media['url'], type=media['type'], name=name)
60 media['book'].medias.add(bookMedia)
62 def backwards(self, orm):
64 # Deleting model 'BookMedia'
65 db.delete_table('catalogue_bookmedia')
67 # Adding field 'Book.odt_file'
68 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)
70 # Adding field 'Book.daisy_file'
71 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)
73 # Adding field 'Book.ogg_file'
74 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)
76 # Adding field 'Book.mp3_file'
77 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)
79 # Removing M2M table for field medias on 'Book'
80 db.delete_table('catalogue_book_medias')
82 # Changing field 'Tag.main_page'
83 db.alter_column('catalogue_tag', 'main_page', self.gf('django.db.models.fields.BooleanField')())
88 'Meta': {'object_name': 'Group'},
89 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
90 'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'unique': 'True'}),
91 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
94 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
95 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
96 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
97 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
98 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
101 'Meta': {'object_name': 'User'},
102 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
103 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
104 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
105 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
106 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
107 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
108 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
109 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
110 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
111 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
112 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
113 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
114 'username': ('django.db.models.fields.CharField', [], {'max_length': '30', 'unique': 'True'})
117 'Meta': {'object_name': 'Book'},
118 '_short_html': ('django.db.models.fields.TextField', [], {}),
119 '_short_html_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
120 '_short_html_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
121 '_short_html_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
122 '_short_html_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
123 '_short_html_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
124 '_short_html_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
125 '_short_html_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
126 '_short_html_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
127 '_tag_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}),
128 '_theme_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}),
129 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
130 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
131 'epub_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
132 'extra_info': ('catalogue.fields.JSONField', [], {}),
133 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
134 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
135 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
136 'medias': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.BookMedia']", 'symmetrical': 'False'}),
137 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'blank': 'True', 'null': 'True', 'to': "orm['catalogue.Book']"}),
138 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
139 'pdf_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
140 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'unique': 'True', 'db_index': 'True'}),
141 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
142 'txt_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
143 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
144 'xml_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'})
146 'catalogue.bookmedia': {
147 'Meta': {'object_name': 'BookMedia'},
148 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
149 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
150 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
151 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
152 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
154 'catalogue.bookstub': {
155 'Meta': {'object_name': 'BookStub'},
156 'author': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
157 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
158 'pd': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
159 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'unique': 'True', 'db_index': 'True'}),
160 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
161 'translator': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
162 'translator_death': ('django.db.models.fields.TextField', [], {'blank': 'True'})
164 'catalogue.filerecord': {
165 'Meta': {'object_name': 'FileRecord'},
166 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
167 'sha1': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
168 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
169 'time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
170 'type': ('django.db.models.fields.CharField', [], {'max_length': '20', 'db_index': 'True'})
172 'catalogue.fragment': {
173 'Meta': {'object_name': 'Fragment'},
174 '_short_html': ('django.db.models.fields.TextField', [], {}),
175 '_short_html_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
176 '_short_html_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
177 '_short_html_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
178 '_short_html_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
179 '_short_html_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
180 '_short_html_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
181 '_short_html_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
182 '_short_html_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
183 'anchor': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
184 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'fragments'", 'to': "orm['catalogue.Book']"}),
185 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
186 'short_text': ('django.db.models.fields.TextField', [], {}),
187 'text': ('django.db.models.fields.TextField', [], {})
190 'Meta': {'unique_together': "(('slug', 'category'),)", 'object_name': 'Tag'},
191 'book_count': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
192 'category': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
193 'death': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
194 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
195 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
196 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
197 'main_page': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
198 'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
199 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
200 'sort_key': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'db_index': 'True'}),
201 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
202 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'})
204 'catalogue.tagrelation': {
205 'Meta': {'unique_together': "(('tag', 'content_type', 'object_id'),)", 'object_name': 'TagRelation', 'db_table': "'catalogue_tag_relation'"},
206 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
207 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
208 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
209 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'to': "orm['catalogue.Tag']"})
211 'contenttypes.contenttype': {
212 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
213 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
214 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
215 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
216 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
220 complete_apps = ['catalogue']