public function uninstallDB()
{
Yii::log(Yii::t('YupeModule.yupe', "{id}->uninstallDB() : Removing DB for {m} requested", ['{m}' => $this->name, '{id}' => $this->getId()]));
$history = Yii::app()->migrator->getMigrationHistory($this->getId(), -1);
if (!empty($history)) {
Yii::app()->getCache()->clear('installedModules', $this->getId(), 'yupe', 'getModulesDisabled', 'modulesDisabled', $this->getId());
Yii::app()->configManager->flushDump();
$message = '';
foreach ($history as $migrationName => $migrationTimeUp) {
// удалить настройки модуля из таблички Settings
Settings::model()->deleteAll('module_id = :module_id', [':module_id' => $this->getId()]);
if ($migrationTimeUp > 0) {
if (Yii::app()->migrator->migrateDown($this->getId(), $migrationName)) {
$message .= Yii::t('YupeModule.yupe', '{m}: Migration was downgrade - {migrationName}', ['{m}' => $this->getId(), '{migrationName}' => $migrationName]) . '<br />';
} else {
$message .= Yii::t('YupeModule.yupe', '{m}: Can\'t downgrade migration - {migrationName}', ['{m}' => $this->getId(), '{migrationName}' => $migrationName]) . '<br />';
}
}
}
Yii::app()->user->setFlash(YFlashMessages::WARNING_MESSAGE, $message);
return true;
}
throw new CException(Yii::t('YupeModule.yupe', 'Error when deleting module DB!'));
}