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

Proposed by Thomas Bechtold
Status: Merged
Approved by: Michael Hall
Approved revision: 70
Merged at revision: not available
Proposed branch: lp://staging/~toabctl/loco-team-portal/duplicate-venues_fix-528828
Merge into: lp://staging/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://staging/~toabctl/loco-team-portal/duplicate-venues_fix-528828
Reviewer Review Type Date Requested Status
Michael Hall (community) Approve
Review via email: mp+20303@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Thomas Bechtold (toabctl) wrote :

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

Revision history for this message
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
Revision history for this message
Daniel Holbach (dholbach) wrote :

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

Revision history for this message
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.

Revision history for this message
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?

Revision history for this message
Michael Hall (mhall119) wrote :

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

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
Thomas Bechtold (toabctl) wrote :

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

Revision history for this message
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