#25884: migrate --run-syncdb doesn't [seem to] work for app without migrations
------------------------------------+--------------------------------------
Reporter: gertjanol | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.9
Severity: Normal | Resolution:
Keywords: syncdb, migrations | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by gertjanol):
* status: closed => new
* resolution: invalid =>
Comment:
Hi Tim,
Thanks, you're right of course, but that doesn't solve my problem. But I
think I've figured it out. If I run `./manage.py migrate --run-syncdb` it
indeed works as intended: the `polls` app is also synced to the database.
However, in our software stack we use a different database for each app,
with a router configured in `DATABASE_ROUTERS` that routes reads, writes,
relations and migrations.
In that case, we need to migrate each database to it's own database.
Before 1.9, we needed to specify the app that was being synced or
migrated. I just found out that with 1.9 that's no longer necessary. In my
example, these two commands gave the expected result: `./manage.py migrate
--run-syncdb` and `./manage.py migrate --run-syncdb --database polls`.
I've updated [https://github.com/gertjanol/django-test my example] at
github to demonstrate our router and settings.
I think this behaviour deserves a mention in the docs. Also, the error I
encountered is not very helpful. It should at least mention that `--run-
syncdb` it not possible when specifying an app. Why is that? When I change
[https://github.com/django/django/blob/e403f2217e67301526a0df5ea5be42e190e00e10/django/core/management/commands/migrate.py#L131
this line] to `if app_label not in executor.loader.migrated_apps and not
run_syncdb` (and move the assignment to `run_syncdb` higher) everything
works as I'd expect. I couldn't find any tests that documented this
behaviour :(.
--
Ticket URL: <https://code.djangoproject.com/ticket/25884#comment:2>
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/067.1613df75caca7263cbb98125445dc0e7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.