Browse files

The migrations that came out of the south demo.

  • Loading branch information...
1 parent d9c1d67 commit cb78beeb8d07bfbf909176fa98b00b4070dbb460 @ericholscher committed Jun 11, 2009
View
53 test_project/polls/migrations/0001_initial.py
@@ -0,0 +1,53 @@
+
+from south.db import db
+from django.db import models
+from polls.models import *
+
+class Migration:
+
+ def forwards(self, orm):
+
+ # Adding model 'Poll'
+ db.create_table('polls_poll', (
+ ('id', models.AutoField(primary_key=True)),
+ ('question', models.CharField(max_length=200)),
+ ('pub_date', models.DateTimeField('date published')),
+ ))
+ db.send_create_signal('polls', ['Poll'])
+
+ # Adding model 'Choice'
+ db.create_table('polls_choice', (
+ ('id', models.AutoField(primary_key=True)),
+ ('poll', models.ForeignKey(orm.Poll)),
+ ('choice', models.CharField(max_length=200)),
+ ('votes', models.IntegerField()),
+ ))
+ db.send_create_signal('polls', ['Choice'])
+
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Poll'
+ db.delete_table('polls_poll')
+
+ # Deleting model 'Choice'
+ db.delete_table('polls_choice')
+
+
+
+ models = {
+ 'polls.poll': {
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'pub_date': ('models.DateTimeField', ["'date published'"], {}),
+ 'question': ('models.CharField', [], {'max_length': '200'})
+ },
+ 'polls.choice': {
+ 'choice': ('models.CharField', [], {'max_length': '200'}),
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'poll': ('models.ForeignKey', ["orm['polls.Poll']"], {}),
+ 'votes': ('models.IntegerField', [], {})
+ }
+ }
+
+ complete_apps = ['polls']
View
37 test_project/polls/migrations/0002_add_slug.py
@@ -0,0 +1,37 @@
+
+from south.db import db
+from django.db import models
+from polls.models import *
+
+class Migration:
+
+ def forwards(self, orm):
+
+ # Adding field 'Poll.slug'
+ db.add_column('polls_poll', 'slug', models.SlugField(null=True))
+
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'Poll.slug'
+ db.delete_column('polls_poll', 'slug')
+
+
+
+ models = {
+ 'polls.poll': {
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'pub_date': ('models.DateTimeField', ["'date published'"], {}),
+ 'question': ('models.CharField', [], {'max_length': '200'}),
+ 'slug': ('models.SlugField', [], {'null': 'True'})
+ },
+ 'polls.choice': {
+ 'choice': ('models.CharField', [], {'max_length': '200'}),
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'poll': ('models.ForeignKey', ["orm['polls.Poll']"], {}),
+ 'votes': ('models.IntegerField', [], {})
+ }
+ }
+
+ complete_apps = ['polls']
View
35 test_project/polls/migrations/0003_populate_slug_data.py
@@ -0,0 +1,35 @@
+from south.db import db
+from django.db import models
+from polls.models import *
+from django.template.defaultfilters import slugify
+
+class Migration:
+
+ def forwards(self, orm):
+ for poll in orm.Poll.objects.all():
+ poll.slug = slugify(poll.question)
+ poll.save()
+
+ def backwards(self, orm):
+ "Write your backwards migration here"
+ for poll in orm.Poll.objects.all():
+ poll.slug = ""
+ poll.save()
+
+
+ models = {
+ 'polls.poll': {
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'pub_date': ('models.DateTimeField', ["'date published'"], {}),
+ 'question': ('models.CharField', [], {'max_length': '200'}),
+ 'slug': ('models.SlugField', [], {'null': 'True'})
+ },
+ 'polls.choice': {
+ 'choice': ('models.CharField', [], {'max_length': '200'}),
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'poll': ('models.ForeignKey', ["orm['polls.Poll']"], {}),
+ 'votes': ('models.IntegerField', [], {})
+ }
+ }
+
+ complete_apps = ['polls']
View
0 test_project/polls/migrations/__init__.py
No changes.
View
2 test_project/settings.py
@@ -74,4 +74,6 @@
'django.contrib.admin',
'polls',
'test_app',
+ 'south',
+ #'django_extensions'
)

0 comments on commit cb78bee

Please sign in to comment.