From 2c45a15212659e44132f9979f695011b62498a52 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 23 Mar 2021 16:54:18 +0000 Subject: [PATCH] Create member foreign key in failed_payment --- .../migrations/0009_auto_20210323_1611.py | 28 +++++++++++++++++++ memberships/models.py | 4 +-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 memberships/migrations/0009_auto_20210323_1611.py diff --git a/memberships/migrations/0009_auto_20210323_1611.py b/memberships/migrations/0009_auto_20210323_1611.py new file mode 100644 index 00000000..e53b13aa --- /dev/null +++ b/memberships/migrations/0009_auto_20210323_1611.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.7 on 2021-03-23 16:11 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('memberships', '0008_member_renewal_date'), + ] + + operations = [ + migrations.RemoveField( + model_name='failedpayment', + name='stripe_customer_id', + ), + migrations.AddField( + model_name='failedpayment', + name='member', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='memberships.member'), + ), + migrations.AlterField( + model_name='member', + name='stripe_customer_id', + field=models.CharField(max_length=255, unique=True), + ), + ] diff --git a/memberships/models.py b/memberships/models.py index 5a3ebbb9..49bed3bc 100644 --- a/memberships/models.py +++ b/memberships/models.py @@ -24,7 +24,7 @@ class Member(models.Model): constitution_agreed = models.BooleanField( help_text='I have read and agree to abide by the Geek.Zone/Constitution.' ) - stripe_customer_id = models.CharField(max_length=255) + stripe_customer_id = models.CharField(max_length=255, unique=True) user = models.OneToOneField(User, on_delete=models.CASCADE) profile_image = models.ImageField( upload_to="images/", @@ -141,7 +141,7 @@ class Membership(models.Model): class FailedPayment(models.Model): - stripe_customer_id = models.CharField(max_length=255) + member = models.ForeignKey(Member, on_delete=models.CASCADE) stripe_subscription_id = models.CharField(max_length=255) stripe_event_type = models.CharField(max_length=255)