Opened 10 years ago
Closed 10 years ago
#25014 closed Bug (duplicate)
Warning about MySQL time format change should not crash migration
Reported by: | Graeme Pietersz | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (2)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Iops, it looks like it is fixed in 1.8. My mistake. I did not find that ticket.
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.