diff mbox

[Branch,~linaro-validation/lava-server/trunk] Rev 407: fix south migration issues from last commit

Message ID 20130115041912.18205.72889.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Andy Doan Jan. 15, 2013, 4:19 a.m. UTC
------------------------------------------------------------
revno: 407
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-server
timestamp: Mon 2013-01-14 15:26:37 -0600
message:
  fix south migration issues from last commit
  
  Basically you can't just delete an extension that's made changes
  to our DB. So this keeps the minimal amount of stuff around from
  the extension.
added:
  lava_projects/
  lava_projects/__init__.py
  lava_projects/extension.py
  lava_projects/migrations/
  lava_projects/migrations/0001_add_model_Project.py
  lava_projects/migrations/0002_add_model_ProjectFormerIdentifier.py
  lava_projects/migrations/0003_auto__del_projectformeridentifier__del_project.py
  lava_projects/migrations/__init__.py
modified:
  lava_server/extension.py
  setup.py


--
lp:lava-server
https://code.launchpad.net/~linaro-validation/lava-server/trunk

You are subscribed to branch lp:lava-server.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-server/trunk/+edit-subscription
diff mbox

Patch

=== added directory 'lava_projects'
=== added file 'lava_projects/__init__.py'
--- lava_projects/__init__.py	1970-01-01 00:00:00 +0000
+++ lava_projects/__init__.py	2013-01-14 21:26:37 +0000
@@ -0,0 +1,19 @@ 
+# Copyright (C) 2010, 2011 Linaro Limited
+#
+# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
+#
+# This file is part of LAVA Server.
+#
+# LAVA Server is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License version 3
+# as published by the Free Software Foundation
+#
+# LAVA Server is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with LAVA Server.  If not, see <http://www.gnu.org/licenses/>.
+
+__version__ = (0, 1, 0, "final", 0)

=== added file 'lava_projects/extension.py'
--- lava_projects/extension.py	1970-01-01 00:00:00 +0000
+++ lava_projects/extension.py	2013-01-14 21:26:37 +0000
@@ -0,0 +1,33 @@ 
+# Copyright (C) 2010, 2011 Linaro Limited
+#
+# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
+#
+# This file is part of LAVA Server.
+#
+# LAVA Server is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License version 3
+# as published by the Free Software Foundation
+#
+# LAVA Server is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with LAVA Server.  If not, see <http://www.gnu.org/licenses/>.
+
+from lava_server.extension import DeprecatedExtension
+
+
+class ProjectExtension(DeprecatedExtension):
+    """
+    This has been deprecated but is just in place for south database migrations
+    """
+
+    @property
+    def app_name(self):
+        return "lava_projects"
+
+    @property
+    def name(self):
+        return "Projects"

=== added directory 'lava_projects/migrations'
=== added file 'lava_projects/migrations/0001_add_model_Project.py'
--- lava_projects/migrations/0001_add_model_Project.py	1970-01-01 00:00:00 +0000
+++ lava_projects/migrations/0001_add_model_Project.py	2013-01-14 21:26:37 +0000
@@ -0,0 +1,91 @@ 
+# 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):
+        
+        # Adding model 'Project'
+        db.create_table('lava_projects_project', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
+            ('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.Group'], null=True, blank=True)),
+            ('is_public', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
+            ('identifier', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=100, db_index=True)),
+            ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
+            ('is_aggregate', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('registered_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='projects', to=orm['auth.User'])),
+            ('registered_on', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+        ))
+        db.send_create_signal('lava_projects', ['Project'])
+
+
+    def backwards(self, orm):
+        
+        # Deleting model 'Project'
+        db.delete_table('lava_projects_project')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': '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']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            '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': {
+            'Meta': {'object_name': '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']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            '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']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', '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'})
+        },
+        'lava_projects.project': {
+            'Meta': {'object_name': 'Project'},
+            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
+            'is_aggregate': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'registered_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
+            'registered_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
+        },
+        'lava_projects.projectfomeridentifier': {
+            'Meta': {'object_name': 'ProjectFomerIdentifier'},
+            'former_identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'former_identifiers'", 'to': "orm['lava_projects.Project']"})
+        }
+    }
+
+    complete_apps = ['lava_projects']

=== added file 'lava_projects/migrations/0002_add_model_ProjectFormerIdentifier.py'
--- lava_projects/migrations/0002_add_model_ProjectFormerIdentifier.py	1970-01-01 00:00:00 +0000
+++ lava_projects/migrations/0002_add_model_ProjectFormerIdentifier.py	2013-01-14 21:26:37 +0000
@@ -0,0 +1,88 @@ 
+# 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):
+        
+        # Adding model 'ProjectFormerIdentifier'
+        db.create_table('lava_projects_projectformeridentifier', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('project', self.gf('django.db.models.fields.related.ForeignKey')(related_name='former_identifiers', to=orm['lava_projects.Project'])),
+            ('former_identifier', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=100, db_index=True)),
+            ('renamed_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='project_former_identifiers_created', to=orm['auth.User'])),
+            ('renamed_on', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+        ))
+        db.send_create_signal('lava_projects', ['ProjectFormerIdentifier'])
+
+
+    def backwards(self, orm):
+        
+        # Deleting model 'ProjectFormerIdentifier'
+        db.delete_table('lava_projects_projectformeridentifier')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': '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']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            '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': {
+            'Meta': {'object_name': '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']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            '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']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', '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'})
+        },
+        'lava_projects.project': {
+            'Meta': {'object_name': 'Project'},
+            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
+            'is_aggregate': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'registered_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
+            'registered_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
+        },
+        'lava_projects.projectformeridentifier': {
+            'Meta': {'object_name': 'ProjectFormerIdentifier'},
+            'former_identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'former_identifiers'", 'to': "orm['lava_projects.Project']"}),
+            'renamed_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'project_former_identifiers_created'", 'to': "orm['auth.User']"}),
+            'renamed_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['lava_projects']

=== added file 'lava_projects/migrations/0003_auto__del_projectformeridentifier__del_project.py'
--- lava_projects/migrations/0003_auto__del_projectformeridentifier__del_project.py	1970-01-01 00:00:00 +0000
+++ lava_projects/migrations/0003_auto__del_projectformeridentifier__del_project.py	2013-01-14 21:26:37 +0000
@@ -0,0 +1,49 @@ 
+# -*- coding: 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 model 'ProjectFormerIdentifier'
+        db.delete_table('lava_projects_projectformeridentifier')
+
+        # Deleting model 'Project'
+        db.delete_table('lava_projects_project')
+
+
+    def backwards(self, orm):
+        # Adding model 'ProjectFormerIdentifier'
+        db.create_table('lava_projects_projectformeridentifier', (
+            ('renamed_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='project_former_identifiers_created', to=orm['auth.User'])),
+            ('renamed_on', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+            ('project', self.gf('django.db.models.fields.related.ForeignKey')(related_name='former_identifiers', to=orm['lava_projects.Project'])),
+            ('former_identifier', self.gf('django.db.models.fields.SlugField')(max_length=100, unique=True, db_index=True)),
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+        ))
+        db.send_create_signal('lava_projects', ['ProjectFormerIdentifier'])
+
+        # Adding model 'Project'
+        db.create_table('lava_projects_project', (
+            ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
+            ('registered_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='projects', to=orm['auth.User'])),
+            ('is_aggregate', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
+            ('is_public', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.Group'], null=True, blank=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
+            ('registered_on', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+            ('identifier', self.gf('django.db.models.fields.SlugField')(max_length=100, unique=True, db_index=True)),
+        ))
+        db.send_create_signal('lava_projects', ['Project'])
+
+
+    models = {
+        
+    }
+
+    complete_apps = ['lava_projects']
\ No newline at end of file

=== added file 'lava_projects/migrations/__init__.py'
=== modified file 'lava_server/extension.py'
--- lava_server/extension.py	2012-02-09 02:56:14 +0000
+++ lava_server/extension.py	2013-01-14 21:26:37 +0000
@@ -122,7 +122,7 @@ 
     """
     Menu (for navigation)
     """
-    
+
     def __init__(self, label, url, sub_menu=None):
         self.label = label
         self.url = url
@@ -160,8 +160,8 @@ 
 
     @property
     def front_page_template(self):
-        return None 
-        
+        return None
+
     def get_front_page_context(self):
         return {}
 
@@ -171,13 +171,34 @@ 
     def get_menu(self):
         pass
 
+class DeprecatedExtension(HeadlessExtension):
+    """
+    If an extension ever contributed to schema changes in the DB, then we
+    can't just delete it alltogher without causing problems with our
+    south migrations. This is a simple class to keep the extension somewhat
+    invisible to the UI, but visible to Django for the DB needs.
+    """
+    @abstractproperty
+    def app_name(self):
+        """
+        Name of this extension's primary django application.
+        (needed for south migrations)
+        """
+
+    def contribute_to_settings(self, settings_module):
+        settings_module['INSTALLED_APPS'].append(self.app_name)
+        settings_module['STATICFILES_PREPEND_LABEL_APPS'].append(self.app_name)
+
+    @property
+    def version(self):
+        return "deprecated"
 
 class Extension(ILavaServerExtension):
     """
     Base class for commmon extensions.
 
     This class implements most of the :class:`IExtension` interface leaving a
-    only handful of more concrete methods and properties to be implemented. 
+    only handful of more concrete methods and properties to be implemented.
     """
 
     def __init__(self, slug):

=== modified file 'setup.py'
--- setup.py	2013-01-11 17:19:47 +0000
+++ setup.py	2013-01-14 21:26:37 +0000
@@ -33,6 +33,8 @@ 
         lava-server = lava_server.manage:main
         [lava_server.commands]
         manage=lava_server.manage:manage
+        [lava_server.extensions]
+        project=lava_projects.extension:ProjectExtension
     """,
     test_suite="lava_server.tests.run_tests",
     license="AGPL",