#23738: Migrations broken with django 1.7.1 when changing null from true to 
false.
----------------------------+--------------------
     Reporter:  niwibe      |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.7
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 Hi!

 I start having strange exceptions when I have migrated a project from
 django 1.7 to 1.7.1


 {{{
 (taiga)[3/5.0.7]{1}niwi@niwi:~/taiga/taiga-back> python manage.py
 sqlmigrate projects 0006
 Traceback (most recent call last):
   File "manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/core/management/__init__.py",
 line 385, in execute_from_command_line
     utility.execute()
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/core/management/__init__.py",
 line 377, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/core/management/base.py",
 line 288, in run_from_argv
     self.execute(*args, **options.__dict__)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/core/management/commands/sqlmigrate.py",
 line 30, in execute
     return super(Command, self).execute(*args, **options)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/core/management/base.py",
 line 338, in execute
     output = self.handle(*args, **options)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/core/management/commands/sqlmigrate.py",
 line 61, in handle
     sql_statements = executor.collect_sql(plan)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/db/migrations/executor.py",
 line 77, in collect_sql
     migration.apply(project_state, schema_editor, collect_sql=True)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/db/migrations/migration.py",
 line 108, in apply
     operation.database_forwards(self.app_label, schema_editor,
 project_state, new_state)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/db/migrations/operations/fields.py",
 line 139, in database_forwards
     schema_editor.alter_field(from_model, from_field, to_field)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/db/backends/schema.py",
 line 473, in alter_field
     self._alter_field(model, old_field, new_field, old_type, new_type,
 old_db_params, new_db_params, strict)
   File "/home/niwi/.virtualenvs/taiga/lib/python3.4/site-
 
packages/Django-1.7.2.dev20141030224451-py3.4.egg/django/db/backends/schema.py",
 line 617, in _alter_field
     sql, params = tuple(zip(*actions))
 ValueError: need more than 0 values to unpack
 }}}

 I start research.

 Firstly I have surprised that the last created migration does not include
 null=False change: https://github.com/taigaio/taiga-back/blob
 /improvements-
 migrations/taiga/projects/migrations/0006_auto_20141029_1040.py but this,
 more surprisingly with django 1.7 emits correct sql migration without
 having null=False in a migration file:

 {{{
 (taiga)[3/5.0.7]niwi@niwi:~/taiga/taiga-back> python manage.py sqlmigrate
 projects 0006
 BEGIN;
 --
 -- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:
 -- Raw Python operation
 --
 ALTER TABLE "projects_project" ALTER COLUMN "total_milestones" SET NOT
 NULL;
 ALTER TABLE "projects_project" ALTER COLUMN "total_milestones" DROP
 DEFAULT;

 COMMIT;
 }}}

 This is a proper behavior?

 But with django 1.7.1 it seems not detects correctly the null attribute
 change, that causes that `actions` variable on
 django/db/backends/schema.py:617 to be empty, which in turn, causes that
 exception.

 I have tried set manually the null=False parameter on the migrations file,
 and it no such effect (works with django 1.7 and raises exception with
 django 1.7.1)

--
Ticket URL: <https://code.djangoproject.com/ticket/23738>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.01c024f099085cc7589197c26b545491%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to