Permalink
Browse files

first try with changing fk field to int field

  • Loading branch information...
1 parent 0b92dae commit 0b25c88f5296bc4bc52844f710079cc27a748279 @kvbik kvbik committed May 27, 2009
Showing with 44 additions and 1 deletion.
  1. +43 −0 djangobaselibrary/sample/migrations/0009_fk_to_int.py
  2. +1 −1 djangobaselibrary/sample/models.py
@@ -0,0 +1,43 @@
+
+from south.db import db
+from django.db import models
+from djangobaselibrary.sample.models import *
+
+class Migration:
+
+ def forwards(self, orm):
+
+ # Changing field 'Spam.type'
+ db.alter_column('sample_spam', 'type_id', models.IntegerField())
+ # and rename
+ db.rename_column('sample_spam', 'type_id', 'type')
+
+
+
+ def backwards(self, orm):
+
+ # rename first
+ db.rename_column('sample_spam', 'type', 'type_id')
+ # Changing field 'Spam.type'
+ db.alter_column('sample_spam', 'type_id', models.ForeignKey(orm['sample.Type']))
+
+
+
+ models = {
+ 'sample.spam': {
+ 'Meta': {'unique_together': "(('name','expires'),)"},
+ 'count': ('models.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'expires': ('models.DateTimeField', [], {}),
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('models.CharField', [], {'max_length': '255'}),
+ 'type': ('models.IntegerField', [], {}),
+ 'weight': ('models.FloatField', [], {})
+ },
+ 'sample.type': {
+ 'description': ('models.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('models.CharField', [], {'unique': 'True', 'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['sample']
@@ -23,7 +23,7 @@ class Spam(models.Model):
expires = models.DateTimeField()
name = models.CharField(max_length=255)
count = models.IntegerField(null=True, blank=True)
- type = models.ForeignKey(Type)
+ type = models.IntegerField()
class Meta:
unique_together = (('name', 'expires'),)

0 comments on commit 0b25c88

Please sign in to comment.