Commits

Anonymous committed fe3e76e

Added unique constraint. Fix #19.

This commit requires migrations to be run.

Comments (0)

Files changed (2)

easy_maps/migrations/0005_auto__add_unique_address_address.py

+# -*- 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):
+        # Removing index on 'Address', fields ['address']
+        db.delete_index('easy_maps_address', ['address'])
+
+        # Adding unique constraint on 'Address', fields ['address']
+        db.create_unique('easy_maps_address', ['address'])
+
+
+    def backwards(self, orm):
+        # Removing unique constraint on 'Address', fields ['address']
+        db.delete_unique('easy_maps_address', ['address'])
+
+        # Adding index on 'Address', fields ['address']
+        db.create_index('easy_maps_address', ['address'])
+
+
+    models = {
+        'easy_maps.address': {
+            'Meta': {'object_name': 'Address'},
+            'address': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'computed_address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+            'geocode_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+            'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['easy_maps']

easy_maps/models.py

 
 
 class Address(models.Model):
-    address = models.CharField(max_length=255, db_index=True)
+    address = models.CharField(max_length=255, unique=True)
     computed_address = models.CharField(max_length=255, null=True, blank=True)
     latitude = models.FloatField(null=True, blank=True)
     longitude = models.FloatField(null=True, blank=True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.