#25818 closed Bug (duplicate)
Unable to sqaush migrations that use RunSQL operations with state_operations
| Reported by: | Simon Kelly | Owned by: | nobody |
|---|---|---|---|
| Component: | Migrations | Version: | 1.7 |
| 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 (last modified by )
As a workaround to this bug: https://code.djangoproject.com/ticket/25817 I have the following custom migration:
operations = [ migrations.RenameField( model_name='bar', old_name='bar_id', new_name='external_id', ), migrations.RunSQL( 'SELECT 1', 'SELECT 1', state_operations=[ 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. 'AlterField' instead of 'migrations.AlterField'. 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'.
Change History (2)
comment:1 by , 10 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 10 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Duplicate of #24278. This has been fixed in 1.8.