django-q icon indicating copy to clipboard operation
django-q copied to clipboard

Unable to run migrations for django-q when using CockroachDB

Open juneeighteen opened this issue 2 years ago • 2 comments

Currently, Django-q does not run with Cockroach Labs as a database backend.

Steps to repeat:

  1. Setup a Cockroach Labs database, and new Django app: https://www.cockroachlabs.com/docs/stable/build-a-python-app-with-cockroachdb-django.html
  2. Install django-q as usual
  3. Run manage.py migrate

You'll receive the error:

django.db.utils.ProgrammingError: column "id" is referenced by the primary key

This seems to be because this migration attempts to drop the primary key, but CockroachDB won't allow that to happen: https://github.com/Koed00/django-q/blob/master/django_q/migrations/0003_auto_20150708_1326.py#L23-L25

My Django migration skills are not yet at ninja status 🥷 , but I'm looking for any potential ways to run the migration scripts without dropping the PK. Any ideas would be appreciated.

juneeighteen avatar May 06 '22 18:05 juneeighteen

This seems bad, but as a proof of concept, I was able to get past the original issue by updating the initial migration to not drop and re-add the primary key field. I'm not sure what a better Django-ism way is to do this though:

https://github.com/Koed00/django-q/compare/master...agilesyndrome:master

image

juneeighteen avatar May 06 '22 19:05 juneeighteen

This same problem happens with Titanium DB (TiDB) (https://en.wikipedia.org/wiki/TiDB). MySQLdb._exceptions.OperationalError: (8200, 'Unsupported drop integer primary key')

the-mace avatar Jun 02 '22 13:06 the-mace