Re: [Django] #27245: can't revert migration with index_together with one field

2016-09-19 Thread Django
#27245: can't revert migration with index_together with one field
-+-
 Reporter:  rm_  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * status:  new => closed
 * resolution:   => wontfix
 * component:  Uncategorized => Database layer (models, ORM)


--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.5c7f27ccd9a1246cc40c32d6ef753190%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27245: can't revert migration with index_together with one field

2016-09-19 Thread Django
#27245: can't revert migration with index_together with one field
---+--
 Reporter:  rm_|Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Uncategorized  |  Version:  1.8
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by rm_):

 If Meta.indexes is supposed to be a generic way to add indexes, then the
 single field for an index is a normal case and there should be no issue.

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.ba86c32f4db83fe5e3200409ab58254a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27245: can't revert migration with index_together with one field

2016-09-19 Thread Django
#27245: can't revert migration with index_together with one field
---+--
 Reporter:  rm_|Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Uncategorized  |  Version:  1.8
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by timgraham):

 `Meta.index_together` is headed toward deprecation in favor of
 `Meta.indexes` (new feature in 1.11). Can the issue be reproduce there? If
 not, I think we can close this as wontfix.

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.b43409bb10b623e9a7d23fa161f5d351%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27245: can't revert migration with index_together with one field

2016-09-19 Thread Django
#27245: can't revert migration with index_together with one field
---+--
 Reporter:  rm_|Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Uncategorized  |  Version:  1.8
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by rm_):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Old description:

> With django 1.8.14 i added a composite index with one field (lame,
> sorry!) because the field is from an abstract model and it seemed the
> cleanest way to handle that:
>
> {{{
> +class Meta:
> +index_together = ['owner']
> }}}
>
> The migrations got created and applied finely:
> {{{
> # -*- coding: utf-8 -*-
> from __future__ import unicode_literals
>
> from django.db import migrations, models
>

> class Migration(migrations.Migration):
>
> dependencies = [
> ('foobar', '0002_auto_20160315_1805'),
> ]
>
> operations = [
> migrations.AlterIndexTogether(
> name='answer',
> index_together=set([('owner',)]),
> ),
> ]
> }}}
>
> Problem is i can't revert the migration:
>
> {{{
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "/venv/local/lib/python2.7/site-
> packages/django/core/management/__init__.py", line 354, in
> execute_from_command_line
> utility.execute()
>   File "/venv/local/lib/python2.7/site-
> packages/django/core/management/__init__.py", line 346, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/venv/local/lib/python2.7/site-
> packages/django/core/management/base.py", line 394, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "/venv/local/lib/python2.7/site-
> packages/django/core/management/base.py", line 445, in execute
> output = self.handle(*args, **options)
>   File "/venv/local/lib/python2.7/site-
> packages/django/core/management/commands/migrate.py", line 222, in handle
> executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
>   File "/venv/local/lib/python2.7/site-
> packages/django/db/migrations/executor.py", line 112, in migrate
> self.unapply_migration(states[migration], migration, fake=fake)
>   File "/venv/local/lib/python2.7/site-
> packages/django/db/migrations/executor.py", line 168, in
> unapply_migration
> state = migration.unapply(state, schema_editor)
>   File "/venv/local/lib/python2.7/site-
> packages/django/db/migrations/migration.py", line 162, in unapply
> operation.database_backwards(self.app_label, schema_editor,
> from_state, to_state)
>   File "/venv/local/lib/python2.7/site-
> packages/django/db/migrations/operations/models.py", line 415, in
> database_backwards
> return self.database_forwards(app_label, schema_editor, from_state,
> to_state)
>   File "/venv/local/lib/python2.7/site-
> packages/django/db/migrations/operations/models.py", line 411, in
> database_forwards
> getattr(new_model._meta, self.option_name, set()),
>   File "/venv/local/lib/python2.7/site-
> packages/django/db/backends/base/schema.py", line 336, in
> alter_index_together
> self._delete_composed_index(model, fields, {'index': True},
> self.sql_delete_index)
>   File "venv/local/lib/python2.7/site-
> packages/django/db/backends/base/schema.py", line 349, in
> _delete_composed_index
> ", ".join(columns),
> ValueError: Found wrong number (2) of constraints for
> cicero_academy_answeracademy(owner_id)
> }}}
>
> So the easy way to fix this is to don't permit te creation of a migration
> with less than two fields. OTOH it would be quite cool to use the non
> composite way of removing an index if the constraints are not enough.
> Whatever you decide i can spend some time on the fix.

New description:

 With django 1.8.14 and postgresql 9.4 i added a composite index with one
 field (lame, sorry!) because the field is from an abstract model and it
 seemed the cleanest way to handle that:

 {{{
 +class Meta:
 +index_together = ['owner']
 }}}

 The migrations got created and applied finely:
 {{{
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals

 from django.db import migrations, models


 class Migration(migrations.Migration):

 dependencies = [
 ('foobar', '0002_auto_20160315_1805'),
 ]

 operations = [
 migrations.AlterIndexTogether(
 name='answer',
 index_together=set([('owner',)]),
 ),
 ]
 }}}

 Problem is i can't revert the migration:

 {{{
   File "manage.py", line 10,