Ejemplo n.º 1
0
 protected function _execute(array $params)
 {
     $db_sql = Database_Helper::schema();
     $file_sql = Database_Helper::install_schema();
     $compare = new Database_Helper();
     $diff = $compare->get_updates($db_sql, $file_sql, TRUE);
     try {
         Database_Helper::insert_sql($diff);
         Cache::instance()->delete(Update::CACHE_KEY_DB_SHEMA);
         Minion_CLI::write('==============================================');
         Minion_CLI::write(__('Database schema updated successfully!'));
         Minion_CLI::write('==============================================');
     } catch (Exception $ex) {
         Minion_CLI::write('==============================================');
         Minion_CLI::write(__('Something went wrong!'));
         Minion_CLI::write('==============================================');
         Minion_CLI::write(__('Error: :message', array(':message' => $ex->getMessage())));
     }
 }
Ejemplo n.º 2
0
 public function get_database()
 {
     if (!ACL::check('update.database_apply')) {
         throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don\'t have permission to :permission', array(':permission' => __('Update database')));
     }
     $db_sql = Database_Helper::schema();
     $file_sql = Database_Helper::install_schema();
     $compare = new Database_Helper();
     $diff = $compare->get_updates($db_sql, $file_sql, TRUE);
     try {
         Database_Helper::insert_sql($diff);
         $this->message('Database schema updated successfully!');
         Cache::instance()->delete(Update::CACHE_KEY_DB_SHEMA);
         $this->response(TRUE);
     } catch (Exception $ex) {
         $this->message('Something went wrong!');
         $this->response(FALSE);
     }
     Kohana::$log->add(Log::INFO, ':user update database')->write();
 }
Ejemplo n.º 3
0
 /**
  * Вставка SQL строк в БД
  * 
  * @param string $sql
  * @throws Validation_Exception
  */
 protected function _insert_data($sql)
 {
     Database_Helper::insert_sql($sql);
 }
Ejemplo n.º 4
0
 /**
  * Деактивация плагина
  * 
  * При деактивации плагина происходит  запуск SQL из 
  * файла `plugin_path/install/drop.sql` и запуск файла
  * `plugin_path/uninstall.php`
  * 
  * @observer plugin_uninstall
  * @return \Plugin_Decorator
  */
 public function deactivate($run_script = FALSE)
 {
     $this->_status = (bool) DB::delete(self::TABLE_NAME)->where('id', '=', $this->id())->execute();
     Plugins::deactivate($this);
     $uninstall_file = $this->path() . 'uninstall' . EXT;
     if ($run_script === TRUE and file_exists($uninstall_file)) {
         Kohana::load($uninstall_file);
     }
     $drop_file = $this->path() . 'install' . DIRECTORY_SEPARATOR . 'drop.sql';
     if (file_exists($drop_file)) {
         Database_Helper::insert_sql(file_get_contents($drop_file));
     }
     Observer::notify('plugin_uninstall', $this->id());
     $this->_on_deactivate();
     return $this->_clear_cache();
 }