3 from south.db import db
4 from south.v2 import DataMigration
5 from django.db import models
6 from forum.migrations import ProgressBar
7 from forum.models.utils import dbsafe_encode
10 from cPickle import loads, dumps
12 from pickle import loads, dumps
14 class Migration(DataMigration):
16 def forwards(self, orm):
17 k_count = orm.KeyValue.objects.count()
18 print "\nConverting %d keyvalue objects:" % k_count
19 progress = ProgressBar(k_count)
21 for kv in orm.KeyValue.objects.all():
23 o = loads(kv.value.encode('utf-8'))
27 kv.value = dbsafe_encode(o, compress_object=True)
33 a_count = orm.Action.objects.count()
34 print "\nConverting %d actions extra fields:" % a_count
35 progress = ProgressBar(a_count)
37 for a in orm.Action.objects.all():
38 a.extra = dbsafe_encode(a.extra, compress_object=True)
45 def backwards(self, orm):
46 "Write your backwards methods here."
50 'Meta': {'object_name': 'Group'},
51 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
52 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
53 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'})
56 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
57 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
58 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
59 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
60 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
63 'Meta': {'object_name': 'User'},
64 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
65 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
66 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
67 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'blank': 'True'}),
68 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
69 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
70 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
71 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
72 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
73 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
74 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
75 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'}),
76 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
78 'contenttypes.contenttype': {
79 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
80 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
81 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
82 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
83 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
86 'Meta': {'object_name': 'Action'},
87 'action_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
88 'action_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
89 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
90 'canceled_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
91 'canceled_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'canceled_actions'", 'null': 'True', 'to': "orm['forum.User']"}),
92 'canceled_ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
93 'extra': ('forum.models.utils.PickledObjectField', [], {'null': 'True'}),
94 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
95 'ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
96 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'null': 'True', 'to': "orm['forum.Node']"}),
97 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['forum.User']"})
99 'forum.actionrepute': {
100 'Meta': {'object_name': 'ActionRepute'},
101 'action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.Action']"}),
102 'by_canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
103 'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
104 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
105 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.User']"}),
106 'value': ('django.db.models.fields.IntegerField', [], {'default': '0'})
108 'forum.authkeyuserassociation': {
109 'Meta': {'object_name': 'AuthKeyUserAssociation'},
110 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
111 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
112 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
113 'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
114 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_keys'", 'to': "orm['forum.User']"})
117 'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
118 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
119 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['forum.Badge']"}),
120 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
121 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
122 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
123 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
124 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'to': "orm['forum.User']"})
127 'Meta': {'unique_together': "(('name', 'type'),)", 'object_name': 'Badge', 'db_table': "u'badge'"},
128 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
129 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'through': "'Award'", 'to': "orm['forum.User']"}),
130 'description': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
131 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
132 'multiple': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
133 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
134 'slug': ('django.db.models.fields.SlugField', [], {'db_index': 'True', 'max_length': '50', 'blank': 'True'}),
135 'type': ('django.db.models.fields.SmallIntegerField', [], {})
138 'Meta': {'object_name': 'KeyValue'},
139 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
140 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
141 'value': ('forum.models.utils.PickledObjectField', [], {'null': 'True'})
144 'Meta': {'object_name': 'MarkedTag'},
145 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
146 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
147 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['forum.Tag']"}),
148 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['forum.User']"})
151 'Meta': {'object_name': 'Node'},
152 'abs_parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_children'", 'null': 'True', 'to': "orm['forum.Node']"}),
153 'active_revision': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'active'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.NodeRevision']"}),
154 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
155 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nodes'", 'to': "orm['forum.User']"}),
156 'body': ('django.db.models.fields.TextField', [], {}),
157 'deleted': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'deleted_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
158 'extra_action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'extra_node'", 'null': 'True', 'to': "orm['forum.Action']"}),
159 'extra_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
160 'extra_ref': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
161 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
162 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
163 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']", 'null': 'True'}),
164 'last_edited': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'edited_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
165 'marked': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
166 'node_type': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),
167 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'null': 'True', 'to': "orm['forum.Node']"}),
168 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
169 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
170 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'nodes'", 'to': "orm['forum.Tag']"}),
171 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
172 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'})
174 'forum.noderevision': {
175 'Meta': {'unique_together': "(('node', 'revision'),)", 'object_name': 'NodeRevision'},
176 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'noderevisions'", 'to': "orm['forum.User']"}),
177 'body': ('django.db.models.fields.TextField', [], {}),
178 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
179 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['forum.Node']"}),
180 'revised_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
181 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
182 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
183 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
184 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})
186 'forum.openidassociation': {
187 'Meta': {'object_name': 'OpenIdAssociation'},
188 'assoc_type': ('django.db.models.fields.TextField', [], {'max_length': '64'}),
189 'handle': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
190 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
191 'issued': ('django.db.models.fields.IntegerField', [], {}),
192 'lifetime': ('django.db.models.fields.IntegerField', [], {}),
193 'secret': ('django.db.models.fields.TextField', [], {'max_length': '255'}),
194 'server_url': ('django.db.models.fields.TextField', [], {'max_length': '2047'})
196 'forum.openidnonce': {
197 'Meta': {'object_name': 'OpenIdNonce'},
198 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
199 'salt': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
200 'server_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
201 'timestamp': ('django.db.models.fields.IntegerField', [], {})
203 'forum.questionsubscription': {
204 'Meta': {'object_name': 'QuestionSubscription'},
205 'auto_subscription': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
206 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
207 'last_view': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 5, 1, 0, 0, 32, 37000)'}),
208 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']"}),
209 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
211 'forum.subscriptionsettings': {
212 'Meta': {'object_name': 'SubscriptionSettings'},
213 'all_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
214 'all_questions_watched_tags': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
215 'enable_notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
216 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
217 'member_joins': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
218 'new_question': ('django.db.models.fields.CharField', [], {'default': "'d'", 'max_length': '1'}),
219 'new_question_watched_tags': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
220 'notify_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
221 'notify_answers': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
222 'notify_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
223 'notify_comments_own_post': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
224 'notify_reply_to_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
225 'questions_answered': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
226 'questions_asked': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
227 'questions_commented': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
228 'questions_viewed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
229 'subscribed_questions': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
230 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'subscription_settings'", 'unique': 'True', 'to': "orm['forum.User']"})
233 'Meta': {'object_name': 'Tag', 'db_table': "u'tag'"},
234 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['forum.User']"}),
235 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
236 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
237 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['forum.User']"}),
238 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
239 'marked_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'marked_tags'", 'through': "'MarkedTag'", 'to': "orm['forum.User']"}),
240 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
241 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
244 'Meta': {'object_name': 'User', '_ormbases': ['auth.User']},
245 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
246 'bronze': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
247 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
248 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
249 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
250 'gold': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
251 'hide_ignored_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
252 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
253 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
254 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
255 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
256 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
257 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
258 'silver': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
259 'subscriptions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscribers'", 'through': "'QuestionSubscription'", 'to': "orm['forum.Node']"}),
260 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}),
261 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
263 'forum.validationhash': {
264 'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'ValidationHash'},
265 'expiration': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 5, 2, 0, 0, 32, 86000)'}),
266 'hash_code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
267 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
268 'seed': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
269 'type': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
270 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
274 complete_apps = ['forum']