Commits

Jason McBrayer committed 17de886

Added support for schema evolution using South.

Note that the schema created by the initial migration is not up to
date with the current stockphoto schema. The goal is that this can be
used for upgrading from stockphoto 0.2.1:

1. Install django 1.0
2. Install South
3. Install new stockphoto
4 ./manage.py migrate stockphoto 0001 --fake # mark initial migration as already run
5../manage.py migrate stockphoto # bring the schema up to date

  • Participants
  • Parent commits dac454a

Comments (0)

Files changed (3)

stockphoto/migrations/0001_initial.py

+
+from south.db import db
+from django.db import models
+from southtest.stockphoto.models import *
+
+class Migration:
+    
+    def forwards(self, orm):
+        
+        # Adding model 'Gallery'
+        db.create_table('stockphoto_gallery', (
+            ('id', models.AutoField(primary_key=True)),
+            ('title', models.CharField(_("title"), max_length=80)),
+            ('slug', models.SlugField()),
+            ('date', models.DateField(_("publication date"), auto_now_add=True)),
+            ('created', models.ForeignKey(orm['auth.User'])),
+            ('display_width', models.IntegerField(_("width to display full images"), default=640)),
+            ('display_height', models.IntegerField(_("height to display full images"), default=480)),
+            ('thumbnail_width', models.IntegerField(_("width to display thumbnails"), default=150)),
+            ('thumbnail_height', models.IntegerField(_("height to display thumbnails"), default=100)),
+        ))
+        db.send_create_signal('stockphoto', ['Gallery'])
+        
+        # Adding model 'Photo'
+        db.create_table('stockphoto_photo', (
+            ('id', models.AutoField(primary_key=True)),
+            ('image', models.ImageField(_("Photograph"))),
+            ('title', models.CharField(_("title"), max_length=80)),
+            ('desc', models.TextField(_("description"), blank=True)),
+            ('gallery', models.ForeignKey(orm.Gallery)),
+            ('photographer', models.CharField(_("photographer"), max_length=80, blank=True)),
+            ('date', models.DateField(_("date photographed"), null=True, blank=True)),
+            ('extra', models.TextField(_("any extra information about the photo"), blank=True)),
+        ))
+        db.send_create_signal('stockphoto', ['Photo'])
+        
+    
+    
+    def backwards(self, orm):
+        
+        # Deleting model 'Gallery'
+        db.delete_table('stockphoto_gallery')
+        
+        # Deleting model 'Photo'
+        db.delete_table('stockphoto_photo')
+        
+    
+    
+    models = {
+        'stockphoto.gallery': {
+            'Meta': {'ordering': "['date',]", 'get_latest_by': "'date'"},
+            'created': ('models.ForeignKey', ["orm['auth.User']"], {}),
+            'date': ('models.DateField', ['_("publication date")'], {'auto_now_add': 'True'}),
+            'display_height': ('models.IntegerField', ['_("height to display full images")'], {'default': '480'}),
+            'display_width': ('models.IntegerField', ['_("width to display full images")'], {'default': '640'}),
+            'id': ('models.AutoField', [], {'primary_key': 'True'}),
+            'slug': ('models.SlugField', [], {}),
+            'thumbnail_height': ('models.IntegerField', ['_("height to display thumbnails")'], {'default': '100'}),
+            'thumbnail_width': ('models.IntegerField', ['_("width to display thumbnails")'], {'default': '150'}),
+            'title': ('models.CharField', ['_("title")'], {'max_length': '80'})
+        },
+        'auth.user': {
+            '_stub': True,
+            'id': ('models.AutoField', [], {'primary_key': 'True'})
+        },
+        'stockphoto.photo': {
+            'date': ('models.DateField', ['_("date photographed")'], {'null': 'True', 'blank': 'True'}),
+            'desc': ('models.TextField', ['_("description")'], {'blank': 'True'}),
+            'extra': ('models.TextField', ['_("any extra information about the photo")'], {'blank': 'True'}),
+            'gallery': ('models.ForeignKey', ["orm['stockphoto.Gallery']"], {}),
+            'id': ('models.AutoField', [], {'primary_key': 'True'}),
+            'image': ('models.ImageField', ['_("Photograph")'], {}),
+            'photographer': ('models.CharField', ['_("photographer")'], {'max_length': '80', 'blank': 'True'}),
+            'title': ('models.CharField', ['_("title")'], {'max_length': '80'})
+        }
+    }
+    
+    complete_apps = ['stockphoto']

stockphoto/migrations/0002_browseable-galleries.py

+
+from south.db import db
+from django.db import models
+from southtest.stockphoto.models import *
+
+class Migration:
+    
+    def forwards(self, orm):
+        
+        # Adding field 'Gallery.browsable'
+        db.add_column('stockphoto_gallery', 'browsable', models.BooleanField(default=True))
+        
+    
+    
+    def backwards(self, orm):
+        
+        # Deleting field 'Gallery.browsable'
+        db.delete_column('stockphoto_gallery', 'browsable')
+        
+    
+    
+    models = {
+        'stockphoto.gallery': {
+            'Meta': {'ordering': "['date',]", 'get_latest_by': "'date'"},
+            'browsable': ('models.BooleanField', [], {'default': 'True'}),
+            'created': ('models.ForeignKey', ["orm['auth.User']"], {}),
+            'date': ('models.DateField', ['_("publication date")'], {'auto_now_add': 'True'}),
+            'display_height': ('models.IntegerField', ['_("height to display full images")'], {'default': '480'}),
+            'display_width': ('models.IntegerField', ['_("width to display full images")'], {'default': '640'}),
+            'id': ('models.AutoField', [], {'primary_key': 'True'}),
+            'slug': ('models.SlugField', [], {}),
+            'thumbnail_height': ('models.IntegerField', ['_("height to display thumbnails")'], {'default': '100'}),
+            'thumbnail_width': ('models.IntegerField', ['_("width to display thumbnails")'], {'default': '150'}),
+            'title': ('models.CharField', ['_("title")'], {'max_length': '80'})
+        },
+        'auth.user': {
+            '_stub': True,
+            'id': ('models.AutoField', [], {'primary_key': 'True'})
+        },
+        'stockphoto.photo': {
+            'date': ('models.DateField', ['_("date photographed")'], {'null': 'True', 'blank': 'True'}),
+            'desc': ('models.TextField', ['_("description")'], {'blank': 'True'}),
+            'extra': ('models.TextField', ['_("any extra information about the photo")'], {'blank': 'True'}),
+            'gallery': ('models.ForeignKey', ["orm['stockphoto.Gallery']"], {}),
+            'id': ('models.AutoField', [], {'primary_key': 'True'}),
+            'image': ('models.ImageField', ['_("Photograph")'], {}),
+            'photographer': ('models.CharField', ['_("photographer")'], {'max_length': '80', 'blank': 'True'}),
+            'title': ('models.CharField', ['_("title")'], {'max_length': '80'})
+        }
+    }
+    
+    complete_apps = ['stockphoto']

stockphoto/migrations/__init__.py

Empty file added.