Commits

Dan Carroll committed 7688524

Add migrations to move activity data to new app

Comments (0)

Files changed (7)

mysite/activitysync/management/commands/updateactivities.py

 from django.core.management.color import no_style
 from django.core.mail import mail_admins
 from optparse import make_option
-from blog.models import Activity
+from activitysync.models import Activity
 
 import os
 import sys

mysite/activitysync/migrations/0001_initial.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding model 'Activity'
+        db.create_table('activitysync_activity', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('title', self.gf('django.db.models.fields.CharField')(max_length=200)),
+            ('link', self.gf('django.db.models.fields.URLField')(max_length=500)),
+            ('source', self.gf('django.db.models.fields.CharField')(max_length=2)),
+            ('username', self.gf('django.db.models.fields.CharField')(max_length=20, blank=True)),
+            ('author', self.gf('django.db.models.fields.CharField')(max_length=20, blank=True)),
+            ('comments', self.gf('django.db.models.fields.TextField')(blank=True)),
+            ('pub_date', self.gf('django.db.models.fields.DateTimeField')()),
+            ('published', self.gf('django.db.models.fields.BooleanField')(default=True)),
+            ('guid', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255, db_index=True)),
+        ))
+        db.send_create_signal('activitysync', ['Activity'])
+
+
+    def backwards(self, orm):
+        
+        # Deleting model 'Activity'
+        db.delete_table('activitysync_activity')
+
+
+    models = {
+        'activitysync.activity': {
+            'Meta': {'ordering': "('-pub_date',)", 'object_name': 'Activity'},
+            'author': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
+            'comments': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'guid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'link': ('django.db.models.fields.URLField', [], {'max_length': '500'}),
+            'pub_date': ('django.db.models.fields.DateTimeField', [], {}),
+            'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'source': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'username': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['activitysync']

mysite/activitysync/migrations/__init__.py

Empty file added.

mysite/activitysync/models.py

     class Meta:
         verbose_name = 'activity'
         verbose_name_plural = 'activities'
-        db_table = 'blog_activities'
         ordering = ('-pub_date',)
         get_latest_by = 'pub_date'
     

mysite/blog/migrations/0002_copy_to_activitysync.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.db import models
+
+class Migration(DataMigration):
+
+    depends_on = (
+        ("activitysync", "0001_initial"),
+    )
+
+    def forwards(self, orm):
+        try:
+            db.delete_table('activitysync_activity')
+        except:
+            print "activitysync_activity does not exist, so don't have to delete"
+
+        db.rename_table('blog_activities', 'activitysync_activity')
+        db.create_table('blog_activities', (('test', models.CharField(max_length=50)),))
+
+    def backwards(self, orm):
+        try:
+            db.delete_table('blog_activities')
+        except:
+            print "blog_activities does not exist, so don't have to delete"
+
+        db.rename_table('activitysync_activity', 'blog_activities')
+        db.create_table('activitysync_activity', (('test', models.CharField(max_length=50)),))
+
+    models = {
+        'activitysync.activity': {
+            'Meta': {'ordering': "('-pub_date',)", 'object_name': 'Activity', 'db_table': "'blog_activities'"},
+            'author': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
+            'comments': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'guid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'link': ('django.db.models.fields.URLField', [], {'max_length': '500'}),
+            'pub_date': ('django.db.models.fields.DateTimeField', [], {}),
+            'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'source': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'username': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'})
+        },
+        'blog.activity': {
+            'Meta': {'ordering': "('-pub_date',)", 'object_name': 'Activity', 'db_table': "'blog_activities'"},
+            'author': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
+            'comments': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'guid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'link': ('django.db.models.fields.URLField', [], {'max_length': '500'}),
+            'pub_date': ('django.db.models.fields.DateTimeField', [], {}),
+            'published': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'source': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'username': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'})
+        },
+        'blog.entry': {
+            'Meta': {'ordering': "('-pub_date',)", 'object_name': 'Entry', 'db_table': "'blog_entries'"},
+            'allow_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'body': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'mod_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'auto_now': 'True', 'blank': 'True'}),
+            'pub_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
+            'snip': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
+            'tags': ('tagging.fields.TagField', [], {}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '200'})
+        }
+    }
+
+    complete_apps = ['activitysync', 'blog']

mysite/blog/migrations/0003_auto__del_activity.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Deleting model 'Activity'
+        db.delete_table('blog_activities')
+
+
+    def backwards(self, orm):
+        
+        # Adding model 'Activity'
+        db.create_table('blog_activities', (
+            ('username', self.gf('django.db.models.fields.CharField')(max_length=20, blank=True)),
+            ('link', self.gf('django.db.models.fields.URLField')(max_length=500)),
+            ('guid', self.gf('django.db.models.fields.CharField')(max_length=255, unique=True, db_index=True)),
+            ('pub_date', self.gf('django.db.models.fields.DateTimeField')()),
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('author', self.gf('django.db.models.fields.CharField')(max_length=20, blank=True)),
+            ('title', self.gf('django.db.models.fields.CharField')(max_length=200)),
+            ('comments', self.gf('django.db.models.fields.TextField')(blank=True)),
+            ('source', self.gf('django.db.models.fields.CharField')(max_length=2)),
+            ('published', self.gf('django.db.models.fields.BooleanField')(default=True)),
+        ))
+        db.send_create_signal('blog', ['Activity'])
+
+
+    models = {
+        'blog.entry': {
+            'Meta': {'ordering': "('-pub_date',)", 'object_name': 'Entry', 'db_table': "'blog_entries'"},
+            'allow_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'body': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'mod_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'auto_now': 'True', 'blank': 'True'}),
+            'pub_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
+            'snip': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
+            'tags': ('tagging.fields.TagField', [], {}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '200'})
+        }
+    }
+
+    complete_apps = ['blog']

mysite/settings.py

     'django.contrib.sessions',
     'django.contrib.sites',
     'django.contrib.flatpages',
+    'activitysync',
     'mysite.blog',
     'disqus',
     'tagging',
                 if fnmatch(key, elt): return True
             return False
 
-    INTERNAL_IPS = glob_list(['127.0.0.1', '192.168.0.*'])
+    INTERNAL_IPS = glob_list(['127.0.0.1', '192.168.*.*'])