/**
  * Runs new migrations
  *
  * @param int $numberOfMigrations
  * @return int
  */
 public static function runMigrations($numberOfMigrations = null)
 {
     // Run DB Migration
     $migrationPath = Yii::getAlias('@app/migrations');
     if (is_dir($migrationPath)) {
         // Force migrate db without confirmation
         $result = ConsoleHelper::run("migrate/up {$numberOfMigrations} --interactive=0");
         $lines = explode(PHP_EOL, $result[1]);
         if ($lines[count($lines) - 1] === "Migrated up successfully.") {
             return 1;
         }
     }
     return 0;
 }
 /**
  * Run DB Migration Down
  *
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionUninstall()
 {
     $addOns = Addon::findAll(['id' => Yii::$app->getRequest()->post('ids')]);
     if (empty($addOns)) {
         throw new NotFoundHttpException(Yii::t('addon', 'Page not found.'));
     } else {
         foreach ($addOns as $addOn) {
             // Run Addon DB Migration
             $migrationPath = Yii::getAlias('@addons') . DIRECTORY_SEPARATOR . $addOn->id . DIRECTORY_SEPARATOR . 'migrations';
             if (is_dir($migrationPath)) {
                 ConsoleHelper::migrateDown($migrationPath, 'migration_' . $addOn->id);
             }
             $addOn->status = $addOn::STATUS_INACTIVE;
             $addOn->installed = $addOn::INSTALLED_OFF;
             $addOn->update();
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('addon', 'The selected items have been uninstalled successfully.'));
         return $this->redirect(['index']);
     }
 }