Permalink
Browse files

`Repository.language` should've been `Repository.languages` and a M2M

  • Loading branch information...
1 parent 5cc21f5 commit 1730f5de7366f3164e6598b282df83814195f2d6 @superbobry committed Jul 30, 2011
@@ -0,0 +1,53 @@
+# 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 field 'Repository.language'
+ db.delete_column('grepo_base_repository', 'language_id')
+
+ # Adding M2M table for field language on 'Repository'
+ db.create_table('grepo_base_repository_language', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('repository', models.ForeignKey(orm['grepo_base.repository'], null=False)),
+ ('language', models.ForeignKey(orm['grepo_base.language'], null=False))
+ ))
+ db.create_unique('grepo_base_repository_language', ['repository_id', 'language_id'])
+
+
+ def backwards(self, orm):
+
+ # User chose to not deal with backwards NULL issues for 'Repository.language'
+ raise RuntimeError("Cannot reverse this migration. 'Repository.language' and its values cannot be restored.")
+
+ # Removing M2M table for field language on 'Repository'
+ db.delete_table('grepo_base_repository_language')
+
+
+ models = {
+ 'grepo_base.language': {
+ 'Meta': {'object_name': 'Language'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'})
+ },
+ 'grepo_base.repository': {
+ 'Meta': {'object_name': 'Repository'},
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'repositories'", 'symmetrical': 'False', 'to': "orm['grepo_base.Language']"}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'score': ('django.db.models.fields.FloatField', [], {'max_length': '255'}),
+ 'source': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'summary': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'updated_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'url': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['grepo_base']
@@ -0,0 +1,58 @@
+# 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):
+
+ # Removing M2M table for field language on 'Repository'
+ db.delete_table('grepo_base_repository_language')
+
+ # Adding M2M table for field languages on 'Repository'
+ db.create_table('grepo_base_repository_languages', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('repository', models.ForeignKey(orm['grepo_base.repository'], null=False)),
+ ('language', models.ForeignKey(orm['grepo_base.language'], null=False))
+ ))
+ db.create_unique('grepo_base_repository_languages', ['repository_id', 'language_id'])
+
+
+ def backwards(self, orm):
+
+ # Adding M2M table for field language on 'Repository'
+ db.create_table('grepo_base_repository_language', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('repository', models.ForeignKey(orm['grepo_base.repository'], null=False)),
+ ('language', models.ForeignKey(orm['grepo_base.language'], null=False))
+ ))
+ db.create_unique('grepo_base_repository_language', ['repository_id', 'language_id'])
+
+ # Removing M2M table for field languages on 'Repository'
+ db.delete_table('grepo_base_repository_languages')
+
+
+ models = {
+ 'grepo_base.language': {
+ 'Meta': {'object_name': 'Language'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
+ 'slug': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'})
+ },
+ 'grepo_base.repository': {
+ 'Meta': {'object_name': 'Repository'},
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'languages': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'repositories'", 'symmetrical': 'False', 'to': "orm['grepo_base.Language']"}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'score': ('django.db.models.fields.FloatField', [], {'max_length': '255'}),
+ 'source': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'summary': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'updated_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'url': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['grepo_base']
@@ -47,7 +47,7 @@ class Repository(models.Model):
help_text=_("`grepo` score for this repository, the bigger the "
"value -- the more help is needed."))
source = models.SmallIntegerField(_("source"), choices=SOURCES)
- language = models.ForeignKey(Language, related_name="repositories")
+ languages = models.ManyToManyField(Language, related_name="repositories")
summary = models.TextField(_("summary"), blank=True, null=True,
help_text=_("project summary, to help the users find what they"
"want."))

0 comments on commit 1730f5d

Please sign in to comment.