Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Fixed referrals migration
Browse files Browse the repository at this point in the history
Allow site column to be nullable, with no default. Related to #968.

ECOM-6230
  • Loading branch information
Clinton Blackburn authored and clintonb committed Oct 27, 2016
1 parent 420afd3 commit e7e5645
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ecommerce/referrals/migrations/0002_auto_20161011_1728.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='referral',
name='site',
field=models.ForeignKey(default=6, to='sites.Site'),
field=models.ForeignKey(to='sites.Site', null=True),
preserve_default=False,
),
migrations.AddField(
Expand Down
26 changes: 26 additions & 0 deletions ecommerce/referrals/migrations/0003_auto_20161027_1738.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
This migration exists to fix the error introduced by https://github.com/edx/ecommerce/pull/968. The 0002 migration
has been updated to setup the site column correctly for new installations. This migration ensures installations
that previously ran 0002 have the column setup correctly.
"""

from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('referrals', '0002_auto_20161011_1728'),
]

operations = [

migrations.AlterField(
model_name='referral',
name='site',
field=models.ForeignKey(to='sites.Site', null=True),
),
]
2 changes: 1 addition & 1 deletion ecommerce/referrals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Referral(TimeStampedModel):
'utm_created_at',
)

site = models.ForeignKey('sites.Site', null=False, blank=False)
site = models.ForeignKey('sites.Site', null=True, blank=False)
basket = models.OneToOneField('basket.Basket', null=True, blank=True)
order = models.OneToOneField('order.Order', null=True, blank=True)
affiliate_id = models.CharField(_('Affiliate ID'), blank=True, default="", max_length=255)
Expand Down

0 comments on commit e7e5645

Please sign in to comment.