Fixes #346. Multiple databases support in management commands.