Repository: dj-stripe/dj-stripe

Issue:
Migration 0008_auto_20150806_1641_squashed_0031_auto_20170606_1708 broken in Django 1.11.8
As of 1.11.8, django/django@b8a2f3c2 causes a fresh migration to break in 0008_auto_20150806_1641_squashed_0031_auto_20170606_1708.

https://code.djangoproject.com/ticket/28305

Migration 0008_auto_20150806_1641_squashed_0031_auto_20170606_1708 broken in Django 1.11.8
As of 1.11.8, django/django@b8a2f3c2 causes a fresh migration to break in 0008_auto_20150806_1641_squashed_0031_auto_20170606_1708.

https://code.djangoproject.com/ticket/28305



Discussion:

Resolving patch:
diff --git a/djstripe/migrations/0008_auto_20150806_1641_squashed_0031_auto_20170606_1708.py b/djstripe/migrations/0008_auto_20150806_1641_squashed_0031_auto_20170606_1708.py
--- a/djstripe/migrations/0008_auto_20150806_1641_squashed_0031_auto_20170606_1708.py
+++ b/djstripe/migrations/0008_auto_20150806_1641_squashed_0031_auto_20170606_1708.py
@@ -386,7 +386,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='charge',
             name='source',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='charges', to='djstripe.StripeSource'),
+            field=models.ForeignKey(help_text='The source used for this charge.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='charges', to='djstripe.StripeSource'),
         ),
         migrations.AddField(
             model_name='charge',
@@ -591,7 +591,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='invoice',
             name='subscription',
-            field=models.ForeignKey(help_text='The subscription that this invoice was prepared for, if any.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='invoices', to='djstripe.Subscription'),
+            field=models.ForeignKey(help_text='The subscription that this invoice was prepared for, if any.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoices', to='djstripe.Subscription'),
         ),
         migrations.AddField(
             model_name='invoice',
@@ -643,7 +643,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='invoiceitem',
             name='subscription',
-            field=models.ForeignKey(help_text='The subscription that this invoice item has been created for, if any.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='invoiceitems', to='djstripe.Subscription'),
+            field=models.ForeignKey(help_text='The subscription that this invoice item has been created for, if any.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoiceitems', to='djstripe.Subscription'),
         ),
         migrations.AddField(
             model_name='plan',
@@ -807,7 +807,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='customer',
             name='default_source',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='customers', to='djstripe.StripeSource'),
+            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='customers', to='djstripe.StripeSource'),
         ),
         migrations.DeleteModel(
             name='TransferChargeFee',
@@ -966,7 +966,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='invoiceitem',
             name='plan',
-            field=models.ForeignKey(help_text='If the invoice item is a proration, the plan of the subscription for which the proration was computed.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='invoiceitems', to='djstripe.Plan'),
+            field=models.ForeignKey(help_text='If the invoice item is a proration, the plan of the subscription for which the proration was computed.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoiceitems', to='djstripe.Plan'),
         ),
         migrations.AlterField(
             model_name='invoiceitem',
@@ -1303,11 +1303,6 @@ class Migration(migrations.Migration):
             name='receipt_sent',
             field=models.BooleanField(default=False, help_text='Whether or not a receipt was sent for this charge.'),
         ),
-        migrations.AlterField(
-            model_name='charge',
-            name='source',
-            field=models.ForeignKey(help_text='The source used for this charge.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='charges', to='djstripe.StripeSource'),
-        ),
         migrations.AlterField(
             model_name='subscription',
             name='application_fee_percent',
@@ -1398,31 +1393,6 @@ class Migration(migrations.Migration):
             name='stripe_id',
             field=djstripe.fields.StripeIdField(max_length=255, unique=True),
         ),
-        migrations.AlterField(
-            model_name='customer',
-            name='default_source',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='customers', to='djstripe.StripeSource'),
-        ),
-        migrations.AlterField(
-            model_name='charge',
-            name='source',
-            field=models.ForeignKey(help_text='The source used for this charge.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='charges', to='djstripe.StripeSource'),
-        ),
-        migrations.AlterField(
-            model_name='invoice',
-            name='subscription',
-            field=models.ForeignKey(help_text='The subscription that this invoice was prepared for, if any.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoices', to='djstripe.Subscription'),
-        ),
-        migrations.AlterField(
-            model_name='invoiceitem',
-            name='plan',
-            field=models.ForeignKey(help_text='If the invoice item is a proration, the plan of the subscription for which the proration was computed.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoiceitems', to='djstripe.Plan'),
-        ),
-        migrations.AlterField(
-            model_name='invoiceitem',
-            name='subscription',
-            field=models.ForeignKey(help_text='The subscription that this invoice item has been created for,Z if any.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoiceitems', to='djstripe.Subscription'),
-        ),
         migrations.AlterField(
             model_name='account',
             name='livemode',
@@ -1433,11 +1403,6 @@ class Migration(migrations.Migration):
             name='metadata',
             field=djstripe.fields.StripeJSONField(blank=True, help_text='A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.', null=True),
         ),
-        migrations.AlterField(
-            model_name='charge',
-            name='account',
-            field=models.ForeignKey(help_text='The account the charge was made on behalf of. Null here indicates that this value was never set.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='charges', to='djstripe.Account'),
-        ),
         migrations.AlterField(
             model_name='charge',
             name='amount_refunded',
@@ -1483,11 +1448,6 @@ class Migration(migrations.Migration):
             name='statement_descriptor',
             field=djstripe.fields.StripeCharField(help_text='An arbitrary string to be displayed on your customer\'s credit card statement. The statement description may not include <>"\' characters, and will appear on your customer\'s statement in capital letters. Non-ASCII characters are automatically stripped. While most banks display this information consistently, some may display it incorrectly or not at all.', max_length=22, null=True),
         ),
-        migrations.AlterField(
-            model_name='charge',
-            name='transfer',
-            field=models.ForeignKey(help_text='The transfer to the destination account (only applicable if the charge was created using the destination parameter).', null=True, on_delete=django.db.models.deletion.CASCADE, to='djstripe.Transfer'),
-        ),
         migrations.AlterField(
             model_name='customer',
             name='account_balance',
@@ -1633,11 +1593,6 @@ class Migration(migrations.Migration):
             name='metadata',
             field=djstripe.fields.StripeJSONField(blank=True, help_text='A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.', null=True),
         ),
-        migrations.AlterField(
-            model_name='invoiceitem',
-            name='plan',
-            field=models.ForeignKey(help_text='If the invoice item is a proration, the plan of the subscription for which the proration was computed.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoiceitems', to='djstripe.Plan'),
-        ),
         migrations.AlterField(
             model_name='invoiceitem',
             name='proration',
@@ -1648,11 +1603,6 @@ class Migration(migrations.Migration):
             name='quantity',
             field=djstripe.fields.StripeIntegerField(help_text='If the invoice item is a proration, the quantity of the subscription for which the proration was computed.', null=True),
         ),
-        migrations.AlterField(
-            model_name='invoiceitem',
-            name='subscription',
-            field=models.ForeignKey(help_text='The subscription that this invoice item has been created for, if any.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoiceitems', to='djstripe.Subscription'),
-        ),
         migrations.AlterField(
             model_name='plan',
             name='interval_count',
diff --git a/djstripe/migrations/0013_remove_card_stripe_id_default.py b/djstripe/migrations/0013_remove_card_stripe_id_default.py
new file mode 100644
--- /dev/null
+++ b/djstripe/migrations/0013_remove_card_stripe_id_default.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.0 on 2017-12-03 01:21
+
+from django.db import migrations
+import djstripe.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('djstripe', '0012_card_customer_from_source'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='card',
+            name='stripe_id',
+            field=djstripe.fields.StripeIdField(max_length=255, unique=True),
+        ),
+    ]
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,6 @@
 
 
 if sys.argv[-1] == 'publish':
-    os.system('python setup.py sdist upload --sign')
     os.system('python setup.py bdist_wheel upload --sign')
     sys.exit()
 


Test patch:
diff --git a/tests/requirements.txt b/tests/requirements.txt
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -4,7 +4,6 @@ django-nose>=1.4.4
 mock>=2.0.0
 nose>=1.3.7
 termcolor>=1.1.0
-tox>=2.3.1
 
 # Docs
 sphinx_rtd_theme>=0.1.9