Re: [Django] #27267: Migrations: Need API to drop a foreign key constraint

2016-09-29 Thread Django
#27267: Migrations: Need API to drop a foreign key constraint
+--
 Reporter:  Melvyn Sopacua  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  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 Melvyn Sopacua):

 I tried for a few hours to reduce it to a test case and failing. There's
 something at play that I'm not considering (all relations have been setup
 identical to the models in the project). So it's a corner-case, but I
 can't pick what in my design is causing it. Taking a break and a fresh
 look in a few days.

--
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/072.271bf72cbb8d590f50c94453495f3208%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27267: Migrations: Need API to drop a foreign key constraint

2016-09-28 Thread Django
#27267: Migrations: Need API to drop a foreign key constraint
+--
 Reporter:  Melvyn Sopacua  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  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 Tim Graham):

 I see the same `RenameField` operation from comment:3 but don't get a
 crash when running it. Tested with PostgreSQL 9.3.

--
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/072.100b9ae4293d5fc386fc4da324e3a7ca%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27267: Migrations: Need API to drop a foreign key constraint

2016-09-28 Thread Django
#27267: Migrations: Need API to drop a foreign key constraint
+--
 Reporter:  Melvyn Sopacua  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  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 Melvyn Sopacua):

 I'm not using the to_field argument explicitedly (but my to_field is not
 named 'id') and that bug report is setup to be limited to a few cases. So
 far my experience is that any change to a model field that affects a
 foreign key pointing to it will blow up. This includes renaming the field,
 changing it's type or making a different field the primary key.

 The minimal case is this:

 {{{#!python
 class ItemType(models.Model):
 item_id = models.AutoField(primary_key=True)
 name = models.CharField(max_length=63)

 class Item(models.Model):
 item_type = models.ForeignKey(ItemType)
 name = models.CharField(max_length=63)
 }}}
 Now change ItemType.item_id to ItemType.item_type_id. If this doesn't blow
 up for you, let me know and I'll make a proper test case.

--
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/072.1dbe39de4072c35fffb21770a8d73814%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27267: Migrations: Need API to drop a foreign key constraint

2016-09-27 Thread Django
#27267: Migrations: Need API to drop a foreign key constraint
+--
 Reporter:  Melvyn Sopacua  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  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 Tim Graham):

 * type:  Uncategorized => Bug


Comment:

 Could it be a duplicate of #22761? The same error message appears there.
 If not, can you provide a minimal set of models to reproduce?

--
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/072.ab9164f6e8177a4bba965465b7f4283a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27267: Migrations: Need API to drop a foreign key constraint

2016-09-26 Thread Django
#27267: Migrations: Need API to drop a foreign key constraint
+--
 Reporter:  Melvyn Sopacua  |Owner:  nobody
 Type:  Uncategorized   |   Status:  new
Component:  Migrations  |  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 Melvyn Sopacua):

 * version:  1.10 => 1.8


Comment:

 Updated version. This may be a 1.8 issue.

 Just ran into the same beast, different trigger. I renamed a primary key
 and runs into the foreign key constraint:

 {{{#!python
 migrations.RenameField(
 model_name='itemtype',
 old_name='item_id',
 new_name='item_type_id',
 ),
 }}}

 Output:
 {{{
 django.db.utils.InternalError: cannot drop constraint dpe_itemtype_pkey on
 table dpe_itemtype because other objects depend on it
 DETAIL:  constraint
 dpe_it_itemtype_ptr_id_3b50b94341daa361_fk_dpe_itemtype_item_id on table
 dpe_itemtypepage depends on index dpe_itemtype_pkey
 constraint dpe_itemb_item_type_id_5c80224be6efb2ca_fk_dpe_itemtype_item_id
 on table dpe_itembase depends on index dpe_itemtype_pkey
 HINT:  Use DROP ... CASCADE to drop the dependent objects too.
 }}}

--
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/072.1c6d0b375538f3c7a33a7931d125d4eb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27267: Migrations: Need API to drop a foreign key constraint

2016-09-25 Thread Django
#27267: Migrations: Need API to drop a foreign key constraint
+--
 Reporter:  Melvyn Sopacua  |Owner:  nobody
 Type:  Uncategorized   |   Status:  new
Component:  Migrations  |  Version:  1.10
 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 Melvyn Sopacua):

 I'll look into it more closely and reduce to bare minimum. If I remove the
 above drop statement, the migration doesn't work.

--
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/072.7dc03ce150755ae9cc7edbd327e800ad%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27267: Migrations: Need API to drop a foreign key constraint

2016-09-24 Thread Django
#27267: Migrations: Need API to drop a foreign key constraint
+--
 Reporter:  Melvyn Sopacua  |Owner:  nobody
 Type:  Uncategorized   |   Status:  new
Component:  Migrations  |  Version:  1.10
 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 Simon Charette):

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


Comment:

 Dropping a foreign key from from a field should be done automatically if
 you convert the field to it's underlying datatype.

 For example, if you have a foreign key pointing to a `CharField` named
 `foo` replacing the `ForeignKey` by a `CharField` should be detected as an
 `AlterField` operation when running `makemigrations`. The `AlterField`
 operation should take care of dropping the constraint on `migrate`.

 For example given these initial models.

 {{{#!python
 class Foo(models.Model):
 id = models.CharField(max_length=20, primary_key=True)

 class Bar(models.Model):
 foo = models.ForeignKey(Foo)
 }}}

 Changing your definitions to

 {{{#!python
 class Foo(models.Model):
 pass  # Will use an implicit AutoField

 class Bar(models.Model):
 foo = models.CharField(max_length=20)
 }}}

 Running `makemigrations` should generate a field with an operation similar
 to

 {{{#!python
 AlterField('Bar', 'foo', models.CharField(max_length=20))
 }}}

 And running the migration containing this operation should drop the
 foreign key constraint.

--
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/072.db3f8d8d2e4f686d84f6a92c8109c5e5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.