yii\console\controllers\CacheController::actionFlushSchema PHP Method

actionFlushSchema() public method

# clears cache schema specified by component id: "db" yii cache/flush-schema db
Since: 2.0.1
public actionFlushSchema ( string $db = 'db' ) : integer
$db string id connection component
return integer exit code
    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);
        }
    }