Ticket #371 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

New --database option for migrate command doesn't work

Reported by: agodfrey@… Owned by: andrew
Priority: major Milestone: 0.7
Component: commands Version: 0.6-pre
Keywords: command, database, multiple Cc:

Description

I attempted using the --database option when migrating and noticed it always used the default database.

settings.py:
DATABASES = {

'default': {

'NAME': 'test',
'ENGINE': 'django.db.backends.mysql',
'USER': 'test',

},
'test': {

'NAME': 'test1',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'test1',

},

}

Using the command:
python manage.py migrate appname --database=test

The default database is used instead of 'test'. It appears the correct database is set at http://south.aeracode.org/browser/south/migration/__init__.py#L177

However, http://south.aeracode.org/browser/south/migration/migrators.py uses the import: from south.db import db. When it does that the last line of that file http://south.aeracode.org/browser/south/db/__init__.py#L75 always sets the db to the default. So even though we passed in a different database at the command line it is always overwritten during the import.

Change History

comment:1 Changed 4 years ago by andrew

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in [2273d7101099]. It was actually because "from x import y" imports copy the namespace, so when we reassign in south.db.db it doesn't reassign in the module.

Note: See TracTickets for help on using tickets.