﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24071	Error with sqlmigrate	djbug	nobody	"I have an app where I create a simple table and then add a partial index directly in SQL using RunSQL & migrations. I get an error with `sqlmigrate` when I use it on a custom migration. 

The command is : `manage.py sqlmigrate myapp 0002_custom.py`

0002_custom.py files looks like this:



{{{
class Migration(migrations.Migration):

    dependencies = [
        ('myapp', '0001_initial'),
    ]

    operations = [
        migrations.RunSQL(
            sql = 'CREATE UNIQUE INDEX test_idx ON book (name, publisher_id) WHERE publisher_id IS NOT NULL;',
        )
    ]

}}}

Here's the error:

{{{
(django1_7) C:\djangoproject>python manage.py sqlmigrate myapp 0002

Traceback (most recent call last):
  File ""manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\core\management\__init__.py"", line 385, in execute_from_command_line
    utility.execute()
  File ""C:\virtualenv\django1_7\lib\site-packages\django\core\management\__init__.py"", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\core\management\base.py"", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\core\management\commands\sqlmigrate.py"", line 30, in execute
    return super(Command, self).execute(*args, **options)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\core\management\base.py"", line 338, in execute
    output = self.handle(*args, **options)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\core\management\commands\sqlmigrate.py"", line 61, in handle
    sql_statements = executor.collect_sql(plan)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\db\migrations\executor.py"", line 77, in collect_sql
    migration.apply(project_state, schema_editor, collect_sql=True)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\db\migrations\migration.py"", line 107, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\db\migrations\operations\special.py"", line 69, in database_forwards
    schema_editor.execute(statement, params=None)
  File ""C:\virtualenv\django1_7\lib\site-packages\django\db\backends\schema.py"", line 96, in execute
    self.collected_sql.append((sql % tuple(map(self.quote_value, params))) + "";"")
TypeError: argument 2 to map() must support iteration

}}}
"	Bug	closed	Migrations	1.7	Normal	duplicate			Unreviewed	0	0	0	0	0	0
