[Django] #25014: Warning about MySQL time format change should not crash migration

11 views
Skip to first unread message

Django

unread,
Jun 22, 2015, 7:56:37 AM6/22/15
to django-...@googlegroups.com
#25014: Warning about MySQL time format change should not crash migration
----------------------------+--------------------
Reporter: fgpietersz | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
When upgrading from MySQL 5.5 to 5.6 the next migration that touches a
table containing a datetime, timestamp or time field gets a warning:

{{{

_mysql_exceptions.Warning: TIME/TIMESTAMP/DATETIME columns of old format
have been upgraded to the new format.
}}}


Unfortunately this causes an exception in MySQLdb, which is not caught, so
the script exits and the rest of the migration is not run, although the
changes to the time related fields are made. This could need a fair amount
of work to clean up if it happens during a complex migration.


{{{
File "./manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/core/management/commands/migrate.py", line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/migrations/executor.py", line 68, in migrate
self.apply_migration(migration, fake=fake)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/migrations/executor.py", line 102, in apply_migration
migration.apply(project_state, schema_editor)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/migrations/migration.py", line 108, in apply
operation.database_forwards(self.app_label, schema_editor,
project_state, new_state)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/migrations/operations/fields.py", line 37, in
database_forwards
field,
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/backends/mysql/schema.py", line 42, in add_field
super(DatabaseSchemaEditor, self).add_field(model, field)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/backends/schema.py", line 388, in add_field
self.execute(sql, params)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/backends/schema.py", line 111, in execute
cursor.execute(sql, params)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/django/db/backends/mysql/base.py", line 129, in execute
return self.cursor.execute(query, args)
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/MySQLdb/cursors.py", line 207, in execute
if not self._defer_warnings: self._warning_check()
File "[path-to-virtualenv]/local/lib/python2.7/site-
packages/MySQLdb/cursors.py", line 117, in _warning_check
warn(w[-1], self.Warning, 3)
_mysql_exceptions.Warning: TIME/TIMESTAMP/DATETIME columns of old format
have been upgraded to the new format.

}}}

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

Django

unread,
Jun 22, 2015, 8:46:47 AM6/22/15
to django-...@googlegroups.com
#25014: Warning about MySQL time format change should not crash migration
----------------------------+--------------------------------------

Reporter: fgpietersz | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Are you on Django 1.7? In Django 1.8, MySQL warnings are no longer
promoted to errors (#23871) so I think this should be fixed there.

--
Ticket URL: <https://code.djangoproject.com/ticket/25014#comment:1>

Django

unread,
Jun 22, 2015, 9:16:07 AM6/22/15
to django-...@googlegroups.com
#25014: Warning about MySQL time format change should not crash migration
----------------------------+--------------------------------------
Reporter: fgpietersz | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by fgpietersz):

* status: new => closed
* resolution: => duplicate


Comment:

Iops, it looks like it is fixed in 1.8. My mistake. I did not find that
ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/25014#comment:2>

Reply all
Reply to author
Forward
0 new messages