@@ -118,6 +118,13 @@ public function optionAliases()
118118 );
119119 }
120120
121+ public function beforeAction ($ action )
122+ {
123+ $ db = \Yii::$ app ->get ($ this ->db );
124+ $ this ->stdout ($ db ->dsn . PHP_EOL , Console::FG_YELLOW );
125+ return parent ::beforeAction ($ action );
126+ }
127+
121128 public function afterAction ($ action , $ result )
122129 {
123130 $ this ->stdout (PHP_EOL );
@@ -184,14 +191,14 @@ function () use ($dsn, $user, $password) {
184191 *
185192 * Creates database and grants permissions to user
186193 *
187- * @param null $root eg. ENV `DB_ENV_MYSQL_ROOT_USER
188- * @param null $rootPassword eg. ENV `DB_ENV_MYSQL_ROOT_USER`
194+ * @param $root eg. ENV `DB_ENV_MYSQL_ROOT_USER
195+ * @param $rootPassword eg. ENV `DB_ENV_MYSQL_ROOT_USER`
189196 *
190197 * @throws \yii\base\ExitException
191198 */
192199 public function actionCreate (
193- $ root = null ,
194- $ rootPassword = null
200+ $ root ,
201+ $ rootPassword
195202 ) {
196203 $ db = \Yii::$ app ->get ($ this ->db );
197204 $ opts = CliHelper::getMysqlOptsFromDsn ($ db );
@@ -216,7 +223,7 @@ public function actionCreate(
216223
217224 // try to create a database for the user
218225 $ this ->stdout (
219- "Creating database ' { $ dbName } ' and granting permissions to user ' {$ user} ' on DSN ' { $ dsn }' with user ' {$ root }' "
226+ "Creating database from DSN for ' {$ user }' with user ' {$ root }' "
220227 );
221228
222229 $ pdo = new \PDO ($ dsn , $ root , $ rootPassword );
@@ -232,12 +239,12 @@ public function actionCreate(
232239 /**
233240 * Remove schema
234241 *
235- * @param null $root eg. ENV `DB_ENV_MYSQL_ROOT_USER
236- * @param null $rootPassword eg. ENV `DB_ENV_MYSQL_ROOT_USER`
242+ * @param $root eg. ENV `DB_ENV_MYSQL_ROOT_USER
243+ * @param $rootPassword eg. ENV `DB_ENV_MYSQL_ROOT_USER`
237244 */
238245 public function actionDestroy (
239- $ root = null ,
240- $ rootPassword = null
246+ $ root ,
247+ $ rootPassword
241248 ) {
242249 if ($ this ->confirm ('This is a destructive operation! Continue? ' , !$ this ->interactive )) {
243250 $ db = \Yii::$ app ->get ($ this ->db );
@@ -331,16 +338,12 @@ public function actionDump()
331338 $ date = date ('ymd_His ' );
332339 $ dir = $ this ->outputPath ;
333340 $ appName = \Yii::$ app ->id ;
334- $ file = $ dir . "/d {$ date }_ {$ appName }.sql " ;
341+ $ file = \Yii:: getAlias ( $ dir . "/d {$ date }_ {$ appName }.sql " ) ;
335342 $ db = \Yii::$ app ->get ($ this ->db );
336343 $ opts = CliHelper::getMysqlOptsFromDsn ($ db );
337344
338345 FileHelper::createDirectory ($ dir );
339346
340- if ($ this ->verbose ) {
341- $ this ->stdout ("Using database {$ db ->dsn }" . PHP_EOL );
342- }
343-
344347 // dump tables with data
345348 $ command = CliHelper::getMysqlCommand ('mysqldump ' , $ db );
346349 $ command ->addArg ('--no-tablespaces ' );
0 commit comments