Exemple #1
0
 /**
  * Проверка БД на расхождение
  * @retun string
  */
 public static function check_database($caching = TRUE)
 {
     $cache = Cache::instance();
     if ($caching === FALSE or ($diff = $cache->get(self::CACHE_KEY_DB_SHEMA)) === NULL) {
         $db_sql = Database_Helper::schema();
         $file_sql = Database_Helper::install_schema();
         $compare = new Database_Helper();
         $diff = $compare->get_updates($db_sql, $file_sql, TRUE);
         $cache->set(self::CACHE_KEY_DB_SHEMA, $diff);
     }
     return $diff;
 }
Exemple #2
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())));
     }
 }
Exemple #3
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();
 }