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