#22583: Allow per-database migrations in multidb configurations
--------------------------------------+------------------------
Reporter: akaariai | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
Currently a database router can be used to skip operations on given model.
However, this approach doesn't work at all for RunPython or RunSQL
commands - especially RunSQL has no notion of which models the SQL
touches. For this reason there should be some way to specify which
databases the migration should apply to. The simplest way seems to be
addition of using kwarg to RunPython and RunSQL commands. For example:
{{{
operations = [
RunSQL("create table foobar(id serial primary key);",
using='default'),
RunSQL("create table foobar(id integer primary key auto_increment)
engine myisam;",
using=('mysql_alias1', 'mysql_alias2'))
]
}}}
However the problem here is that this assumes the migrations know the used
database aliases. This doesn't work for 3rd party app migrations. For
these cases "for_vendor='mysql'/'postgresql'/..." argument would work
better.
Still, there might be need to allow skipping whole apps for migations -
say you have a 3rd party app you don't want to migrate on database other -
my understanding is that one can only skip all model operations on given
database, but there is no way to force skip of RunSQL and RunPython
commands, too. If it would be possible to define that the app in whole
shouldn't be migrated on database other, then there would be no problem
when running manage.py migrate.
--
Ticket URL: <https://code.djangoproject.com/ticket/22583>
Django <https://code.djangoproject.com/>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.01dc117ac1a4fdd09af8397e8971d178%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.