Opened 8 years ago

Closed 8 years ago

#24071 closed Bug (duplicate)

Error with sqlmigrate

Reported by: djbug 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

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

Change History (1)

comment:1 Changed 8 years ago by Claude Paroz

Resolution: duplicate
Status: newclosed

Duplicate of #23909 (should be fixed very soon in 1.7.2)

Note: See TracTickets for help on using tickets.
Back to Top