Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2019-05-02 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  closed
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * status:  new => closed
 * resolution:   => duplicate
 * needs_tests:  1 => 0


Comment:

 Adding `migrations.AlterModelBases()` to a migration `operations` from
 [https://github.com/django/django/pull/11222 patch] proposed for #23521
 fix this issue for me, e.g.
 {{{ #!python
 operations = [
 migrations.AlterModelBases('suba', (models.Model,)),
 migrations.RenameModel(
 old_name='Base',
 new_name='BrokenBase',
 ),
 migrations.RenameField(
 model_name='suba',
 old_name='base_ptr',
 new_name='brokenbase_ptr',
 ),
 ]
 }}}
 Marking as a duplicate of #23521.

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2019-02-28 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Nuwan Goonasekera):

 Based on the patch proposed by Markus Holtermann, I've created a migration
 operation that extends the existing RenameModel migration, and it seems to
 be working as expected. Sharing in case someone else runs into the same
 issue. I've only tested this with Django 2.1.7.


 {{{
 from django.db import migrations, models

 class RenameModelAndBaseOperation(migrations.RenameModel):

 def __init__(self, old_name, new_name):
 super(RenameModelAndBaseOperation, self).__init__(old_name,
 new_name)

 def state_forwards(self, app_label, state):
 old_remote_model = '%s.%s' % (app_label, self.old_name_lower)
 new_remote_model = '%s.%s' % (app_label, self.new_name_lower)
 to_reload = []
 # change all bases affected by rename
 for (model_app_label, model_name), model_state in
 state.models.items():
 if old_remote_model in model_state.bases:
 new_bases_tuple = tuple(
 new_remote_model if base == old_remote_model
 else base
 for base in model_state.bases)
 state.models[model_app_label, model_name].bases =
 new_bases_tuple
 to_reload.append((model_app_label, model_name))
 super(RenameModelAndBaseOperation, self).state_forwards(app_label,
 state)
 state.reload_models(to_reload, delay=True)

 class Migration(migrations.Migration):

 operations = [
 RenameModelAndBaseOperation(
 old_name='Cloud',
 new_name='CloudOld',
 ),
 ]
 }}}

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2018-01-11 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Aaron Riedener):

 @Markus Holtermann
 I managed to fix the issue for my very specific case using a modified
 version of your draft patch.
 I did not need to modify the base.py and state.py nor did i need to add
 the new class "AlterModelBases"

 Can you tell me what needs to be improved in your opinion to make it ready
 to be implemented on the django master?

 What is the restirction that it does not work with sqlite?

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2018-01-11 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Aaron Riedener):

 * cc: Aaron Riedener (added)


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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2018-01-11 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Matthijs Kooijman):

 * cc: Matthijs Kooijman (added)


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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2018-01-11 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Matthijs Kooijman):

 This bug seems to also apply to proxy subclasses. E.g. if you start with:

 {{{
 from django.db import models

 class Base(models.Model):
 foo = models.BooleanField()

 class SubA(BrokenBase):
 class Meta:
 proxy = True
 }}}

 And then go to the same steps as described in the initial post, you will
 get the same error as shown in the initial posted (tested with Django
 2.0.1). I also tested with an abstract superclass, but that works as
 expected (probably because an abstract class is not involved in any
 migrations).

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2017-08-12 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Markus Holtermann):

 Looks like using a `AlterModelBases` operation wouldn't cut it in the
 given case as the bases alteration needs to happen as part of the
 `RenameModel` operation.

 
[https://github.com/MarkusH/django/commit/b7bf79ed38bb1a5d730c9b106ef6e5819ebb3a4e
 Here] is a very early patch including debugging output and some other
 cruft that wouldn't be part of a proper patch that does not work on
 SQLite, yet.

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2017-08-12 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Markus Holtermann):

 * version:  1.9 => master
 * needs_tests:  0 => 1


Comment:

 So, this is due to the fact that Django doesn't have a way to alter model
 bases. For whatever reason. I don't have a solution at hand right now. But
 there are a few other tickets (one being #23521) that suffer from the same
 issue.

 Idea for a solution:
 * add `AlterModelBases` migration operation
 * extend autodetector to detect model bases changes

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2017-08-12 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.9
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Markus Holtermann):

 When I try to run `makemigrations` after *step 0* with the code you
 provided I get the following system check failure:
 {{{
 $ ./manage.py makemigrations
 SystemCheckError: System check identified some issues:

 ERRORS:
 ticket26488.SubModel.basemodel_ptr: (fields.E007) Primary keys must not
 have null=True.
 HINT: Set null=False on the field, or remove primary_key=True
 argument.
 }}}

 Further, neither steps 0-2 nor steps 1-2 work for me. It comes down to
 `django.core.exceptions.FieldError: Auto-generated field 'basemodel_ptr'
 in class 'SubModel' for parent_link to base class 'BaseModel' clashes with
 declared field of the same name.` both times.

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2017-08-10 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.9
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Christopher Neugebauer):

 So the previous example is a bit evil. Here's a reduced example that
 *works* in Django 1.11:

 **Step 0**
 {{{
 class BaseModel(models.Model):
 pass


 class SubModel(BaseModel):
 basemodel_ptr = models.OneToOneField(BaseModel, null=True)
 }}}
 Run `makemigrations`

 **Step 1**
 {{{
 class BaseModel(models.Model):
 pass


 class SubModel(BaseModel):
 pass
 }}}
 Run `makemigrations`


 **Step 2**
 {{{
 class RenamedBaseModel(models.Model):
 pass


 class SubModel(RenamedBaseModel):
 pass

 }}}
 Run `makemigrations`


 If you start with Step 0, you can successfully `migrate` at the end of
 step 2.
 If you start with Step 1, `migrate` breaks, but with a new error:

 `django.core.exceptions.FieldError: Auto-generated field 'basemodel_ptr'
 in class 'SubModel' for parent_link to base class 'BaseModel' clashes with
 declared field of the same name.`

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2017-08-10 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.9
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Christopher Neugebauer):

 So here's something fun. Here's how you *can* create a model with a base
 class whose name you can change, and Migrations will be happy.

 1. Create a model `SubModel`, it must derive from `models.Model`.
 2. Create a new base class, `BaseModel`, it must derive from
 `models.Model`
 3. Add: `basemodel_ptr = OneToOneField(BaseModel, null=True)` on
 `SubModel`. The field *must* be named like the class name of the new base
 class.
 4. Automatically create a migration
 5. Create a data migration that creates a new `BaseModel(id=submodel.id)`
 for each `SubModel` instance. This step is only necessary if you have
 created `SubModel` objects. Otherwise, just use an automatic default.
 6. Set the base model of `SubModel` to `BaseModel`
 7. Automatically create a migration
 8. Rename `BaseModel` to `RenamedBaseModel`
 9. Automatically create a migration, accepting the two automatic
 suggestions
 10. Migrate!

 At this point, you can see that `RenamedBaseModel` works as expected. It
 appears as though everything here works, as long as you aren't tracking
 the base class when migrations first creates the model.

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2017-06-23 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.9
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Piranha Phish):

 Just wanted to confirm that this is affecting me as well. I'm receiving
 the new error message "… clashes with declared field of the same name"
 when trying to apply a migration in which a base class of MTI is renamed.

 The two versions of the workaround class proposed by Simon don't seem to
 work for me. Is there any other known workaround?

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model

2017-06-13 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.9
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by kesterlester):

 Replying to [comment:5 Tim Graham]:
 > As reported in #28243 (closed as duplicate), after
 ecd625e830ef765d5e60d5db7bc6e3b7ffc76d06,  the error is now something like
 "FieldError: Auto-generated field 'a_ptr' in class 'B' for parent_link to
 base class 'A' clashes with declared field of the same name."

 Ah - such a relief to find this bug report!   ~24 hours ago I hit this
 problem in my first django project.  Being a newbie I presumed I was doing
 something wrong and have been trying all sorts of things (without success)
 to allow me to rename a base class without losing all the data that's now
 in my database.  I'll leave the renaming issue alone now and await a
 patch.  I don't feel anywhere near experienced enough yet to try to patch
 things myself, but maybe later?

 In agreement with Tim's comment I see:

 {{{ jango.core.exceptions.FieldError: Auto-generated field 'content_ptr'
 in class 'Answer' for parent_link to base class 'Content' clashes with
 declared field of the same name. }}}

 as a result of me trying to rename a multi-table inheritance base class
 (having no non-automatic fields) from name "Content" to something else,
 when class Answer derives from Content.

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


Re: [Django] #26488: migrate crashes when renaming a multi-table inheritance base model (was: migrate raises InvalidBasesError if you rename a multitable inheritance base model)

2017-05-26 Thread Django
#26488: migrate crashes when renaming a multi-table inheritance base model
-+-
 Reporter:  Christopher  |Owner:  nobody
  Neugebauer |
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.9
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Graham):

 As reported in #28243 (closed as duplicate), after
 ecd625e830ef765d5e60d5db7bc6e3b7ffc76d06,  the error is now something like
 "FieldError: Auto-generated field 'a_ptr' in class 'B' for parent_link to
 base class 'A' clashes with declared field of the same name."

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