ajout de la PK id
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 24 Mar 2011 20:42:07 +0000 (16:42 -0400)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 24 Mar 2011 20:42:07 +0000 (16:42 -0400)
project/gcast/migrations/0002_auto__add_field_compte_id.py [new file with mode: 0644]
project/gcast/migrations/0003_creation_pk.py [new file with mode: 0644]
project/gcast/migrations/0004_auto__chg_field_compte_exten__chg_field_compte_id__add_unique_compte_i.py [new file with mode: 0644]
project/gcast/migrations/0005_auto__chg_field_compte_id.py [new file with mode: 0644]
project/gcast/models.py

diff --git a/project/gcast/migrations/0002_auto__add_field_compte_id.py b/project/gcast/migrations/0002_auto__add_field_compte_id.py
new file mode 100644 (file)
index 0000000..ecf4c3d
--- /dev/null
@@ -0,0 +1,37 @@
+# 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 field 'Compte.id'
+        db.add_column('gcast_compte', 'id', self.gf('django.db.models.fields.CharField')(max_length=8, null=True, blank=True), keep_default=False)
+    
+    def backwards(self, orm):
+        
+        # Deleting field 'Compte.id'
+        db.delete_column('gcast_compte', 'id')
+    
+    
+    models = {
+        'gcast.compte': {
+            'Meta': {'object_name': 'Compte'},
+            'bureau': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'categorie': ('django.db.models.fields.CharField', [], {'default': "'users-locaux'", 'max_length': '64'}),
+            'cidname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'email': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'exten': ('django.db.models.fields.CharField', [], {'max_length': '8', 'primary_key': 'True'}),
+            'fullname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'id': ('django.db.models.fields.CharField', [], {'max_length': '8', 'null': 'True', 'blank': 'True'}),
+            'nat': ('django.db.models.fields.CharField', [], {'default': "'no'", 'max_length': '8'}),
+            'pavillon': ('django.db.models.fields.CharField', [], {'default': '543', 'max_length': '4'}),
+            'secret': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'voicemailcode': ('django.db.models.fields.CharField', [], {'max_length': '8'})
+        }
+    }
+    
+    complete_apps = ['gcast']
diff --git a/project/gcast/migrations/0003_creation_pk.py b/project/gcast/migrations/0003_creation_pk.py
new file mode 100644 (file)
index 0000000..42c5f39
--- /dev/null
@@ -0,0 +1,35 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.db import models
+
+class Migration(DataMigration):
+    
+    def forwards(self, orm):
+        "Write your forwards methods here."
+        for i, cpt in enumerate(orm.Compte.objects.all()):
+            cpt.id = i+1
+            cpt.save()   
+    
+    def backwards(self, orm):
+        "Write your backwards methods here."
+    
+    models = {
+        'gcast.compte': {
+            'Meta': {'object_name': 'Compte'},
+            'bureau': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'categorie': ('django.db.models.fields.CharField', [], {'default': "'users-locaux'", 'max_length': '64'}),
+            'cidname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'email': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'exten': ('django.db.models.fields.CharField', [], {'max_length': '8', 'primary_key': 'True'}),
+            'fullname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'id': ('django.db.models.fields.CharField', [], {'max_length': '8', 'null': 'True', 'blank': 'True'}),
+            'nat': ('django.db.models.fields.CharField', [], {'default': "'no'", 'max_length': '8'}),
+            'pavillon': ('django.db.models.fields.CharField', [], {'default': '543', 'max_length': '4'}),
+            'secret': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'voicemailcode': ('django.db.models.fields.CharField', [], {'max_length': '8'})
+        }
+    }
+    
+    complete_apps = ['gcast']
diff --git a/project/gcast/migrations/0004_auto__chg_field_compte_exten__chg_field_compte_id__add_unique_compte_i.py b/project/gcast/migrations/0004_auto__chg_field_compte_exten__chg_field_compte_id__add_unique_compte_i.py
new file mode 100644 (file)
index 0000000..77fba5a
--- /dev/null
@@ -0,0 +1,50 @@
+# 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):
+        
+        # Changing field 'Compte.exten'
+        db.alter_column('gcast_compte', 'exten', self.gf('django.db.models.fields.CharField')(max_length=8, unique=True))
+
+        # Changing field 'Compte.id'
+        db.alter_column('gcast_compte', 'id', self.gf('django.db.models.fields.CharField')(max_length=8, unique=True, primary_key=True))
+
+        # Adding unique constraint on 'Compte', fields ['id']
+        db.create_unique('gcast_compte', ['id'])
+    
+    
+    def backwards(self, orm):
+        
+        # Changing field 'Compte.exten'
+        db.alter_column('gcast_compte', 'exten', self.gf('django.db.models.fields.CharField')(max_length=8, primary_key=True))
+
+        # Changing field 'Compte.id'
+        db.alter_column('gcast_compte', 'id', self.gf('django.db.models.fields.CharField')(max_length=8, null=True, blank=True))
+
+        # Removing unique constraint on 'Compte', fields ['id']
+        db.delete_unique('gcast_compte', ['id'])
+    
+    
+    models = {
+        'gcast.compte': {
+            'Meta': {'object_name': 'Compte'},
+            'bureau': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'categorie': ('django.db.models.fields.CharField', [], {'default': "'users-locaux'", 'max_length': '64'}),
+            'cidname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'email': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'exten': ('django.db.models.fields.CharField', [], {'max_length': '8', 'unique': 'True'}),
+            'fullname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'id': ('django.db.models.fields.CharField', [], {'max_length': '8', 'unique': 'True', 'primary_key': 'True'}),
+            'nat': ('django.db.models.fields.CharField', [], {'default': "'no'", 'max_length': '8'}),
+            'pavillon': ('django.db.models.fields.CharField', [], {'default': '543', 'max_length': '4'}),
+            'secret': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'voicemailcode': ('django.db.models.fields.CharField', [], {'max_length': '8'})
+        }
+    }
+    
+    complete_apps = ['gcast']
diff --git a/project/gcast/migrations/0005_auto__chg_field_compte_id.py b/project/gcast/migrations/0005_auto__chg_field_compte_id.py
new file mode 100644 (file)
index 0000000..928361b
--- /dev/null
@@ -0,0 +1,38 @@
+# 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):
+        
+        # Changing field 'Compte.id'
+        db.alter_column('gcast_compte', 'id', self.gf('django.db.models.fields.AutoField')(primary_key=True))
+    
+    
+    def backwards(self, orm):
+        
+        # Changing field 'Compte.id'
+        db.alter_column('gcast_compte', 'id', self.gf('django.db.models.fields.CharField')(unique=True, max_length=8, primary_key=True))
+    
+    
+    models = {
+        'gcast.compte': {
+            'Meta': {'object_name': 'Compte'},
+            'bureau': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'categorie': ('django.db.models.fields.CharField', [], {'default': "'users-locaux'", 'max_length': '64'}),
+            'cidname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'email': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'exten': ('django.db.models.fields.CharField', [], {'max_length': '8', 'unique': 'True'}),
+            'fullname': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'nat': ('django.db.models.fields.CharField', [], {'default': "'no'", 'max_length': '8'}),
+            'pavillon': ('django.db.models.fields.CharField', [], {'default': '543', 'max_length': '4'}),
+            'secret': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'voicemailcode': ('django.db.models.fields.CharField', [], {'max_length': '8'})
+        }
+    }
+    
+    complete_apps = ['gcast']
index 4e6a215..1050f63 100644 (file)
@@ -18,7 +18,7 @@ NAT = (
     )
 
 class Compte(models.Model):
-    exten = models.CharField(max_length=8, primary_key=True)
+    exten = models.CharField(max_length=8, unique=True)
     categorie = models.CharField(max_length=64,choices=CATEGORIES, default=CATEGORIES[0][0])
     fullname = models.CharField(max_length=256)
     cidname = models.CharField(max_length=256)