Re: [Django] #24026: migration RunPython operation ignores db router allow_migrate

2014-12-19 Thread Django
#24026: migration RunPython operation ignores db router allow_migrate
+--
 Reporter:  dikamilo|Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  duplicate
 Keywords:  migration   | 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
 * needs_better_patch:   => 0
 * resolution:   => duplicate
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Please see #22583 and #23749. I think this is a duplicate of those issues.
 Thanks!

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


[Django] #24026: migration RunPython operation ignores db router allow_migrate

2014-12-19 Thread Django
#24026: migration RunPython operation ignores db router allow_migrate
+---
 Reporter:  dikamilo|  Owner:  nobody
 Type:  Bug | Status:  new
Component:  Migrations  |Version:  1.7
 Severity:  Normal  |   Keywords:  migration
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0   |  UI/UX:  0
+---
 I wrote custom router for SaaS architecture to handle different databases
 and custom management command to apply migrations for all databases. I'm
 sure that this router and command works properly.

 All migrations works fine except migrations with {{{RunPython}}} command
 in operations - that migrations are executed ignoring {{{allow_migrate}}}
 policy in database router.

 For example in one of my app i have several migrations generated by django
 (manage.py makemigrations). My router checks if given app models should be
 in given database and if it return False, django not create table, not
 change schema etc. All works just fine and model is not in database. But
 if I create empty migration and add RunPython operation that add initial
 data to database for given model, django execute this migration throwing
 out error {{{django.db.utils.OperationalError: no such table}}}.

 I checked django code and for example in {{{AlterModelTable}}} operation
 {{{database_forwards}}} method uses {{{self.allowed_to_migrate}}}:

 {{{
 def database_forwards(self, app_label, schema_editor, from_state,
 to_state):
 old_apps = from_state.render()
 new_apps = to_state.render()
 old_model = old_apps.get_model(app_label, self.name)
 new_model = new_apps.get_model(app_label, self.name)
 if self.allowed_to_migrate(schema_editor.connection.alias,
 new_model):
 schema_editor.alter_db_table(
 new_model,
 old_model._meta.db_table,
 new_model._meta.db_table,
 )
 }}}
 To compare RunPython {{{database_forwards}}} method look like this (cut
 comments):

 {{{
 def database_forwards(self, app_label, schema_editor, from_state,
 to_state):
 self.code(from_state.render(), schema_editor)
 }}}

 I think it's a bug and {{{RunPython}}} command should use
 {{{self.allowed_to_migrate}}} 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/051.34205d3d6489ca71b8a524c702c38343%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.