Merge lp:~toabctl/loco-team-portal/duplicate-venues_fix-528828 into lp:loco-team-portal

Proposed by Thomas Bechtold on 2010-02-28
Status: Merged
Approved by: Michael Hall on 2010-03-17
Approved revision: 70
Merged at revision: not available
Proposed branch: lp:~toabctl/loco-team-portal/duplicate-venues_fix-528828
Merge into: lp:loco-team-portal
Diff against target: 61 lines (+47/-0)
2 files modified
loco_directory/venues/migrations/0002_add_unique_together.py (+44/-0)
loco_directory/venues/models.py (+3/-0)
To merge this branch: bzr merge lp:~toabctl/loco-team-portal/duplicate-venues_fix-528828
Reviewer Review Type Date Requested Status
Michael Hall (community) 2010-02-28 Approve on 2010-03-08
Review via email: mp+20303@code.launchpad.net
To post a comment you must log in.
Thomas Bechtold (toabctl) wrote :

Anything wrong with this fix? Why does nobody comment/merge it? Just busy?

Michael Hall (mhall119) wrote :

It looks good to me. Can we query the database before running the migration, to make sure there aren't currently any duplicates? If there are, it will probably fail to apply the database changes.

review: Approve
Daniel Holbach (dholbach) wrote :

Has this been merged? What exactly needs to be done? By the IS team?

Michael Hall (mhall119) wrote :

We just need to make sure that the data we currently have doesn't conflict with the new constraints before IS runs the migration script.

Daniel Holbach (dholbach) wrote :

What's the easiest way to do that? A test-case? A management command? What needs to be done with that data?

Michael Hall (mhall119) wrote :

We don't have that many venues, a simple visual check over the ones we do have should be enough.

Thomas Bechtold (toabctl) wrote :

i think there are no duplicates. would be good to make this schema change before we get more and more venues.

Michael Hall (mhall119) wrote :

I agree, Jono is pushing more use, so the longer we wait on this, the more venues we'll have to check

Thomas Bechtold (toabctl) wrote :

@mhall119: so please change status to "Approved" so we can merge this.

Michael Hall (mhall119) wrote :

Sorry, thought I had done that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'loco_directory/venues/migrations/0002_add_unique_together.py'
2--- loco_directory/venues/migrations/0002_add_unique_together.py 1970-01-01 00:00:00 +0000
3+++ loco_directory/venues/migrations/0002_add_unique_together.py 2010-02-28 09:34:14 +0000
4@@ -0,0 +1,44 @@
5+
6+from south.db import db
7+from django.db import models
8+from venues.models import *
9+
10+class Migration:
11+
12+ def forwards(self, orm):
13+
14+ # Creating unique_together for [name, country, city] on Venue.
15+ db.create_unique('venues_venue', ['name', 'country', 'city'])
16+
17+ # Creating unique_together for [longitude, latitude] on Venue.
18+ db.create_unique('venues_venue', ['longitude', 'latitude'])
19+
20+
21+
22+ def backwards(self, orm):
23+
24+ # Deleting unique_together for [longitude, latitude] on Venue.
25+ db.delete_unique('venues_venue', ['longitude', 'latitude'])
26+
27+ # Deleting unique_together for [name, country, city] on Venue.
28+ db.delete_unique('venues_venue', ['name', 'country', 'city'])
29+
30+
31+
32+ models = {
33+ 'venues.venue': {
34+ 'Meta': {'unique_together': "(('name', 'country', 'city'), ('longitude', 'latitude'))"},
35+ 'address': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
36+ 'city': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
37+ 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
38+ 'country': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
39+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
40+ 'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
41+ 'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
42+ 'map_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
43+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
44+ 'venue_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
45+ }
46+ }
47+
48+ complete_apps = ['venues']
49
50=== modified file 'loco_directory/venues/models.py'
51--- loco_directory/venues/models.py 2010-01-11 08:35:34 +0000
52+++ loco_directory/venues/models.py 2010-02-28 09:34:14 +0000
53@@ -23,6 +23,9 @@
54 map_url = models.URLField(help_text=_('Map URL for the Venue'), verbose_name=_('URL of the Map'), max_length=200, verify_exists=False, blank=True, null=True)
55 comment = models.TextField(help_text=_('Comment about the Venue'), blank=True, null=True)
56
57+ class Meta:
58+ unique_together = ( ('name', 'country', 'city'), ('longitude', 'latitude'), )
59+
60 #add manager
61 objects = VenueManager()
62

Subscribers

People subscribed via source and target branches