Skip to content

Commit

Permalink
Take DJSTRIPE_SUBSCRIBER_MODEL_MIGRATION_DEPENDENCY into account
Browse files Browse the repository at this point in the history
  • Loading branch information
hgezim authored and jleclanche committed Aug 7, 2018
1 parent ccc61a2 commit d7c0725
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion djstripe/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@

DJSTRIPE_SUBSCRIBER_MODEL = getattr(settings, "DJSTRIPE_SUBSCRIBER_MODEL", settings.AUTH_USER_MODEL)

# Needed here for external apps that have added the DJSTRIPE_SUBSCRIBER_MODEL
# *not* in the '__first__' migration of the app, which results in:
# ValueError: Related model 'DJSTRIPE_SUBSCRIBER_MODEL' cannot be resolved
# Context: https://github.com/dj-stripe/dj-stripe/issues/707
DJSTRIPE_SUBSCRIBER_MODEL_MIGRATION_DEPENDENCY = getattr(
settings, "DJSTRIPE_SUBSCRIBER_MODEL_MIGRATION_DEPENDENCY", "__first__"
)

DJSTRIPE_SUBSCRIBER_MODEL_DEPENDENCY = migrations.swappable_dependency(DJSTRIPE_SUBSCRIBER_MODEL)

if DJSTRIPE_SUBSCRIBER_MODEL != settings.AUTH_USER_MODEL:
DJSTRIPE_SUBSCRIBER_MODEL_DEPENDENCY = migrations.migration.SwappableTuple(
(DJSTRIPE_SUBSCRIBER_MODEL.split(".", 1)[0], DJSTRIPE_SUBSCRIBER_MODEL_MIGRATION_DEPENDENCY),
DJSTRIPE_SUBSCRIBER_MODEL
)


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
DJSTRIPE_SUBSCRIBER_MODEL_DEPENDENCY,
]

operations = [
Expand Down

0 comments on commit d7c0725

Please sign in to comment.