#25818: Unable to sqaush migrations that use RunSQL operations with
state_operations
----------------------------+--------------------
Reporter: snopoke | 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
----------------------------+--------------------
As a workaround to this bug: https://code.djangoproject.com/ticket/25817 I
have the following custom migration:
{{{#!python
operations = [
migrations.RunSQL(
'ALTER TABLE form_processor_bar RENAME COLUMN bar_id TO
external_id',
'ALTER TABLE form_processor_bar RENAME COLUMN external_id TO
bar_id',
state_operations=[
migrations.RenameField(
model_name='bar',
old_name='bar_id',
new_name='external_id',
),
migrations.AlterField(
model_name='bazz',
name='bar',
field=models.ForeignKey(to='form_processor.Bar',
to_field=b'external_id'),
preserve_default=True,
),
]
)
]
}}}
When I try and squash this migration I get the following error:
{{{
$ ./manage.py squashmigrations form_processor 0002
Will squash the following migrations:
- 0001_initial
- 0002_rename_bar_id_to_external_id
Do you wish to proceed? [yN] y
Optimizing...
Traceback (most recent call last):
File "./manage.py", line 73, in <module>
execute_from_command_line(sys.argv)
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "/home/skelly/.virtualenvs/hq/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 "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/core/management/commands/squashmigrations.py", line 130,
in handle
fh.write(writer.as_string())
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 131, in as_string
operation_string, operation_imports =
OperationWriter(operation).serialize()
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 88, in serialize
arg_string, arg_imports = MigrationWriter.serialize(arg_value)
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 263, in serialize
item_string, item_imports = cls.serialize(item)
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 350, in serialize
return cls.serialize_deconstructed(*value.deconstruct())
File "/home/skelly/.virtualenvs/hq/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 226, in
serialize_deconstructed
module, name = path.rsplit(".", 1)
ValueError: need more than 1 value to unpack
}}}
On further examination it seems that the 'path' to the operation is being
passed in without the module reference i.e. 'RenameField' instead of
'migrations.RenameField'. It's also possible that something else is going
wrong since all the other paths being passed to 'serialize_deconstructed'
are for actual field classes e.g. 'django.db.models.CharField'.
--
Ticket URL: <https://code.djangoproject.com/ticket/25818>
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/050.7cad2d6212d1f16cd91ba6590cc57aed%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.