Commits

Diego Búrigo Zacarão committed 8877d2a

Data migration for SVN and HG backend changes

- As Tx now is not anymore supporting the field 'branch'
for those VCSs, it's necessary to migrate it on earlier
Tx versions.
- To set a branch of a repository, still it's possible to
use the full branch url in the 'root' field.
- Added initial schema migration to the VCS app too

  • Participants
  • Parent commits 6e4d450

Comments (0)

Files changed (4)

File transifex/projects/migrations/0004_hg_comps_data_migration.py

+# -*- coding: utf-8 -*-
+
+from south.db import db
+from django.db import models
+from projects.models import *
+
+class Migration:
+    
+    def forwards(self, orm):
+        
+        for c in Component.objects.filter(_unit__type='hg', 
+                                          _unit__vcsunit__branch='tip'):
+            c.unit.branch = ''
+            c.unit.save()
+            if c.slug=='tip':
+                c.slug='default'
+            if c.name=='tip':
+                c.name='default'
+            c.save()
+            c.clear_cache()
+
+    def backwards(self, orm):
+
+        for c in Component.objects.filter(_unit__type='hg', 
+                                          _unit__vcsunit__branch=''):
+            c.unit.branch = 'tip'
+            c.unit.save()
+            c.clear_cache()
+            
+    models = {
+        'auth.group': {
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'unique_together': "(('content_type', 'codename'),)"},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'codebases.unit': {
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_checkout': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
+            'root': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'type': ('django.db.models.fields.CharField', [], {'max_length': '10'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'unique_together': "(('app_label', 'model'),)", 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'languages.language': {
+            'Meta': {'db_table': "'translations_language'"},
+            'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}),
+            'code_aliases': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100', 'null': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}),
+            'nplurals': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+            'pluralequation': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'specialchars': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'projects.component': {
+            'Meta': {'unique_together': "(('project', 'slug'),)"},
+            '_unit': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['codebases.Unit']", 'unique': 'True', 'null': 'True', 'db_column': "'unit_id'", 'blank': 'True'}),
+            'allows_submission': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'file_filter': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'full_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'i18n_type': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'long_description': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'long_description_html': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'pofiles': ('django.contrib.contenttypes.generic.GenericRelation', [], {'to': "orm['translations.POFile']"}),
+            'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['projects.Project']"}),
+            'releases': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['txcollections.CollectionRelease']", 'null': 'True', 'blank': 'True'}),
+            'should_calculate': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '30', 'db_index': 'True'}),
+            'source_lang': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'submission_type': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'projects.project': {
+            'anyone_submit': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'bug_tracker': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+            'collections': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['txcollections.Collection']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'feed': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'homepage': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'long_description': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'long_description_html': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'maintainers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'null': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '30', 'db_index': 'True'}),
+            'tags': ('TagField', [], {})
+        },
+        'translations.pofile': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'filename'),)"},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'error': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'filename': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'fuzzy': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'fuzzy_perc': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_msgmerged': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'is_pot': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
+            'language': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['languages.Language']", 'null': 'True'}),
+            'language_code': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+            'rev': ('txcommon.db.models.IntegerTupleField', [], {'max_length': '64', 'null': 'True'}),
+            'total': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trans': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trans_perc': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'untrans': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'untrans_perc': ('django.db.models.fields.PositiveIntegerField', [], {'default': '100'})
+        },
+        'txcollections.collection': {
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'homepage': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'long_description': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'long_description_html': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '30', 'db_index': 'True'}),
+            'tags': ('TagField', [], {})
+        },
+        'txcollections.collectionrelease': {
+            'Meta': {'unique_together': "(['slug', 'collection'],)", 'db_table': "'collections_release'"},
+            'collection': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'releases'", 'to': "orm['txcollections.Collection']"}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'develfreeze_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+            'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'homepage': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'long_description': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'long_description_html': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'release_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '30', 'db_index': 'True'}),
+            'stringfreeze_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+        }
+    }
+    
+    complete_apps = ['projects']

File transifex/vcs/migrations/0001_initial.py

+
+from south.db import db
+from django.db import models
+from vcs.models import *
+
+class Migration:
+    
+    def forwards(self, orm):
+        
+        # Adding model 'VcsUnit'
+        db.create_table('vcs_vcsunit', (
+            ('unit_ptr', orm['vcs.VcsUnit:unit_ptr']),
+            ('branch', orm['vcs.VcsUnit:branch']),
+            ('web_frontend', orm['vcs.VcsUnit:web_frontend']),
+        ))
+        db.send_create_signal('vcs', ['VcsUnit'])
+        
+    
+    
+    def backwards(self, orm):
+        
+        # Deleting model 'VcsUnit'
+        db.delete_table('vcs_vcsunit')
+        
+    
+    
+    models = {
+        'codebases.unit': {
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_checkout': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
+            'root': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'type': ('django.db.models.fields.CharField', [], {'max_length': '10'})
+        },
+        'vcs.vcsunit': {
+            'branch': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'unit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['codebases.Unit']", 'unique': 'True', 'primary_key': 'True'}),
+            'web_frontend': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
+        }
+    }
+    
+    complete_apps = ['vcs']

File transifex/vcs/migrations/0002_svn_data_migration.py

+
+from south.db import db
+import os
+from django.db import models
+from vcs.models import *
+
+class Migration:
+
+    depends_on = (
+        ("codebases", "0001_initial"),
+    )
+
+    def forwards(self, orm):
+
+        for unit in VcsUnit.objects.filter(type='svn'):
+            if unit.branch == 'trunk':
+                unit.root = os.path.join(unit.root, 'trunk')
+            else:
+                unit.root = os.path.join(unit.root, 'branches/%s' % unit.branch)
+            unit.branch = '';
+            unit.save()
+
+    def backwards(self, orm):
+
+        for unit in VcsUnit.objects.filter(type='svn'):
+            if unit.root.endswith('/trunk'):
+                unit.root = unit.root.split('/trunk')[0]
+                unit.branch = 'trunk'
+            elif '/branches/' in unit.root:
+                unit.root = unit.root.split('/branches/')[0]
+                unit.branch = unit.root.split('/branches/')[1]
+            unit.save()
+    
+    models = {
+        'codebases.unit': {
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_checkout': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
+            'root': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'type': ('django.db.models.fields.CharField', [], {'max_length': '10'})
+        },
+        'vcs.vcsunit': {
+            'branch': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'unit_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['codebases.Unit']", 'unique': 'True', 'primary_key': 'True'}),
+            'web_frontend': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
+        }
+    }
+    
+    complete_apps = ['vcs']

File transifex/vcs/migrations/__init__.py

Empty file added.