anexia-it / django-rest-passwordreset

An extension of django rest framework, providing a configurable password reset strategy
BSD 3-Clause "New" or "Revised" License
419 stars 148 forks source link

Django OperationalError 1075, 'Incorrect table definition' multiple auto column issue. #86

Open Ebtessam opened 4 years ago

Ebtessam commented 4 years ago

Running version 0.9.7 on a MariaDB docker container.

root@ac695e436a58:/# mysql -V
mysql  Ver 15.1 Distrib 10.3.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Getting this SQL error when running migrations.

django.db.utils.OperationalError: (1075, 'Incorrect table definition; there can be only one auto column and it must be defined as a key')

Here's part of the traceback:

  Applying django_rest_passwordreset.0002_pk_migration...ALTER TABLE `django_rest_passwordreset_resetpasswordtoken` ADD COLUMN `id` integer NULL; (params [])
ALTER TABLE `django_rest_passwordreset_resetpasswordtoken` ALTER COLUMN `id` DROP DEFAULT; (params [])
ALTER TABLE `django_rest_passwordreset_resetpasswordtoken` MODIFY `id` integer AUTO_INCREMENT NULL; (params [])

This is mentioned in several old issues but supposedly version 0.9.6, 0.9.7 solved it. But it seems to be an issue for me am I missing something?

Thank you :)

anx-cbenke commented 4 years ago

Sorry for the late reply! Is this still an issue for you?

I've just tried it on a fresh install with 10.1.44-MariaDB and django-rest-passwordreset-1.1.0 and had no issues running the migrations.

ebadia commented 3 years ago

Same problem here.

Running migrations: Applying django_rest_passwordreset.0002_pk_migration...Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute return self.cursor.execute(query, args) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute res = self._query(query) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query db.query(q) File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 259, in query _mysql.connection.query(self, query) MySQLdb._exceptions.OperationalError: (1075, 'Incorrect table definition; there can be only one auto column and it must be defined as a key')

Running

Thanks!

ebadia commented 3 years ago

All working now. Just reset migrations to zero and recreate all tables for django_rest_passwordreset. Thanks!