Dj-stripe: Migration error on Django 2.0

Created on 13 Dec 2017  路  6Comments  路  Source: dj-stripe/dj-stripe

This my requirements file:

certifi==2017.11.5
chardet==3.0.4
dj-stripe==1.0.0.post1
Django==2.0
django-polymorphic==1.3
gunicorn==19.7.1
idna==2.6
jsonfield==2.0.2
pkg-resources==0.0.0
psycopg2==2.7.3.2
python-doc-inherit==0.3.0
pytz==2017.3
requests==2.18.4
stripe==1.75.3
tqdm==4.19.5
urllib3==1.22

You'll see that I'm using Django 2.0 and the latest version of dj-stripe.

My Python version:

$ python -V
Python 3.6.3

I'm on Ubuntu 16.04. My Postgres version is 9.5.10.

This is the error log from trying to run python manage.py migrate. python manage.py makemigrations ran fine.

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, djstripe, sessions
Running migrations:
  Applying djstripe.0008_auto_20150806_1641_squashed_0031_auto_20170606_1708...

Traceback (most recent call last):
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
  return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: constraint "djstripe_charge_account_id_597fef70_fk_djstripe_account_id" for relation "djstripe_charge" already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "manage.py", line 15, in <module>
  execute_from_command_line(sys.argv)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
  utility.execute()
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
  self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
  self.execute(*args, **cmd_options)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
  output = self.handle(*args, **options)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 200, in handle
  fake_initial=fake_initial,
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 117, in migrate
  state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
  state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
  state = migration.apply(state, schema_editor)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 90, in __exit__
  self.execute(sql)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 117, in execute
  cursor.execute(sql, params)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
  return super().execute(sql, params)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
  return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
  return executor(sql, params, many, context)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
  return self.cursor.execute(sql, params)
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
  raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/daniel/ctx/myvenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
  return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: constraint "djstripe_charge_account_id_597fef70_fk_djstripe_account_id" for relation "djstripe_charge" already exists
bug migrations

Most helpful comment

I had success with commit 89faf06b4753a64b27fa654206301d55cc7f69cb, the latest commits to master were not working for me on Django 2.0.1 & Postgres. I did not test every commit past this point.
pip install git+git://github.com/dj-stripe/dj-stripe.git@89faf06b4753a64b27fa654206301d55cc7f69cb

All 6 comments

you might need to fake the migration.

See #615 for some advice on this. We need to get a release out soon so that the fix is live. :)

We need to get a release out soon so that the fix is live. :)

That would be awesome. Anything I can do to get us closer to issuing the next release? 馃槉

@justinmayer yes actually, #609 needs more tests to recover the lost coverage, if you can contribute them we can merge it faster ;)

I had success with commit 89faf06b4753a64b27fa654206301d55cc7f69cb, the latest commits to master were not working for me on Django 2.0.1 & Postgres. I did not test every commit past this point.
pip install git+git://github.com/dj-stripe/dj-stripe.git@89faf06b4753a64b27fa654206301d55cc7f69cb

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Guest007 picture Guest007  路  6Comments

MarcMacia picture MarcMacia  路  3Comments

PabloCastellano picture PabloCastellano  路  3Comments

PabloCastellano picture PabloCastellano  路  3Comments

therefromhere picture therefromhere  路  4Comments