public function actionFlushSchema($db = 'db')
{
$connection = Yii::$app->get($db, false);
if ($connection === null) {
$this->stdout("Unknown component \"{$db}\".\n", Console::FG_RED);
return self::EXIT_CODE_ERROR;
}
if (!$connection instanceof \yii\db\Connection) {
$this->stdout("\"{$db}\" component doesn't inherit \\yii\\db\\Connection.\n", Console::FG_RED);
return self::EXIT_CODE_ERROR;
} elseif (!$this->confirm("Flush cache schema for \"{$db}\" connection?")) {
return static::EXIT_CODE_NORMAL;
}
try {
$schema = $connection->getSchema();
$schema->refresh();
$this->stdout("Schema cache for component \"{$db}\", was flushed.\n\n", Console::FG_GREEN);
} catch (\Exception $e) {
$this->stdout($e->getMessage() . "\n\n", Console::FG_RED);
}
}