#25216: DB migration bug in 1.8.3 when creating ManyToMany relation.
----------------------------+---------------------
     Reporter:  cx44yale    |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.8
     Severity:  Normal      |   Keywords:  migrate
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+---------------------
 Hi,
 I have the following very simple code:

 from django.contrib.auth.models import User

 class Agent(models.Model):

     name = models.CharField(max_length=100)
     users = models.ManyToManyField(User, related_name='accessible_agents',
 default=[])

 and when I have an empty database, and do python manage.py migrate.

 It gives me error, and I tested on 1.7.8, it works fine.

 Operations to perform:
   Synchronize unmigrated apps: staticfiles, download, messages
   Apply all migrations: admin, auth, contenttypes, sessions
 Synchronizing apps without migrations:
   Creating tables...
     Creating table download_agent
     Running deferred SQL...
 Traceback (most recent call last):
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 62, in execute
     return self.cursor.execute(sql)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/db/backends/mysql/base.py", line 124, in execute
     return self.cursor.execute(query, args)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 220, in execute
     self.errorhandler(self, exc, value)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
     raise errorvalue
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 209, in execute
     r = self._query(query)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 371, in _query
     rowcount = self._do_query(q)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 335, in _do_query
     db.query(q)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/connections.py", line 280, in query
     _mysql.connection.query(self, query)
 _mysql_exceptions.OperationalError: (1005, "Can't create table
 'portal_aperture.#sql-403_b3' (errno: 150)")

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

 Traceback (most recent call last):
   File "manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/core/management/__init__.py", line 338, in
 execute_from_command_line
     utility.execute()
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/core/management/__init__.py", line 330, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/core/management/base.py", line 393, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/core/management/base.py", line 444, in execute
     output = self.handle(*args, **options)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/core/management/commands/migrate.py", line 179, in handle
     created_models = self.sync_apps(connection,
 executor.loader.unmigrated_apps)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/core/management/commands/migrate.py", line 317, in
 sync_apps
     cursor.execute(statement)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 79, in execute
     return super(CursorDebugWrapper, self).execute(sql, params)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 64, in execute
     return self.cursor.execute(sql, params)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/db/utils.py", line 97, in __exit__
     six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/utils/six.py", line 658, in reraise
     raise value.with_traceback(tb)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 62, in execute
     return self.cursor.execute(sql)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/django/db/backends/mysql/base.py", line 124, in execute
     return self.cursor.execute(query, args)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 220, in execute
     self.errorhandler(self, exc, value)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
     raise errorvalue
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 209, in execute
     r = self._query(query)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 371, in _query
     rowcount = self._do_query(q)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/cursors.py", line 335, in _do_query
     db.query(q)
   File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
 packages/MySQLdb/connections.py", line 280, in query
     _mysql.connection.query(self, query)
 django.db.utils.OperationalError: (1005, "Can't create table
 'portal_aperture.#sql-403_b3' (errno: 150)")

 Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/25216>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.7b65e9c6a9f8d108ff2f93d444e9f99e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to