Opened 9 years ago
Closed 9 years ago
#26208 closed Bug (needsinfo)
Squashing migrations in which unique=True is added and then removed for Charfield cannot migrate backwards on Postgres
Reported by: | Linus Schoemaker | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.9 |
Severity: | Normal | Keywords: | migrations squash charfield unique |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This bug can be reproduced as follows:
- Create a model with a CharField with unique=True
- Create a migration
- Alter the model so that CharField is no longer unique
- Create a new migration
- Squash the two migrations
- Migrate forwards, and then backwards
Error output:
psycopg2.ProgrammingError: relation "survey_respondent_email_b0f1dc87_like" already exists The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 200, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/migrations/executor.py", line 96, in migrate self._migrate_all_backwards(plan, full_plan, fake=fake) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_backwards self.unapply_migration(states[migration], migration, fake=fake) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/migrations/executor.py", line 218, in unapply_migration state = migration.unapply(state, schema_editor) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/migrations/migration.py", line 172, in unapply operation.database_backwards(self.app_label, schema_editor, from_state, to_state) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 206, in database_backwards self.database_forwards(app_label, schema_editor, from_state, to_state) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 482, in alter_field old_db_params, new_db_params, strict) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/backends/postgresql/schema.py", line 116, in _alter_field self.execute(like_index_statement) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 110, in execute cursor.execute(sql, params) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/var/lib/jenkins/shiningpanda/jobs/914dc536/virtualenvs/d41d8cd9/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation "survey_respondent_email_b0f1dc87_like" already exists
This issue was not present in version 1.9.0, but appeared in version 1.9.2 (or 1.9.1). Probably related to #26034
Change History (2)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I followed those steps but couldn't reproduce. Could list the exact commands for each step to ensure I didn't misinterpret?