Closed smichae closed 9 years ago
It uses db
of the target. You can have multiple loggers configured and each could use its own connection so migration should be applied to connection specified in the target.
Why do you want to override it?
@samdark I ran into this while trying to apply the migration to my test database. In the console configuration, I have my production database in 'db', test database in 'testdb', and have also included authManager, which doesn't define a db, and is therefore using the default db setting. For any of my own migrations, I just append --db=testdb
to the yii migrate command, and expected this particular migration to obey the db parameter. When I saw that there was a db customization in authManager, it became clear why the db parameter was being ignored, but it was a little confusing at first since it completely disregarded my override. Since the migration is strictly rbac-related, it would seem to make more sense to use the command line parameter if it was passed in instead of always using the one in the configuration.
On a more general note, if this isn't the suggested method for migrating non-production databases from the command line, please let me know, as this seemed to have been a fairly acceptable pattern with 1.1. (If there is a more acceptable pattern, it may also be worth it to add to the docs, assuming I didn't miss it somewhere. Off the top of my head, it almost seems like a split yii and yii-test for the console may be a better method?)
Thanks!
https://github.com/yiisoft/yii2-app-advanced/blob/master/tests/codeception/bin/yii
try /path/to/tests/codeception/bin/yii migrate
p.s. i think it need move to codeception extension
Sounds like a misuse of dev/production environments, otherwise why would you need to connect to a 'production' DB from a dev environment?
Agreed that the codeception/bin/yii is the way to go here - I just hadn't dug into that code deep enough when I submitted this issue.
With commit b8cb5e2a28ccbd60235eeded97838cc75063a386, the RBAC migration script will always use the db configured in the authManager, ignoring any command line argument like
yiic migrate --migrationPath=@yii/rbac/migrations/ --db=testdb
.This probably won't be a widespread issue, and a workaround to temporarily change the authManager config db is easy enough, but if this will continue to be the behavior of the script, a note in the documentation about the inconsistency from the regular behavior might save others some time down the road.