Example #1
0
 public function uninstall()
 {
     Piwik_DropTables(Piwik_Common::prefixTable('user_dashboard'));
 }
Example #2
0
 /**
  * Purges old report/metric data.
  * 
  * If $keepBasicMetrics is false, old numeric tables will be dropped, otherwise only
  * the metrics not in $metricsToKeep will be deleted.
  * 
  * If $reportPeriodsToKeep is an empty array, old blob tables will be dropped. Otherwise,
  * specific reports will be deleted, except reports for periods in $reportPeriodsToKeep.
  * 
  * @param bool $optimize If tables should be optimized after rows are deleted. Normally,
  *                       this is handled by a scheduled task.
  */
 public function purgeData($optimize = false)
 {
     // find archive tables to purge
     list($oldNumericTables, $oldBlobTables) = $this->getArchiveTablesToPurge();
     // process blob tables first, since archive status is stored in the numeric archives
     if (!empty($oldBlobTables)) {
         // if no reports should be kept, drop tables, otherwise drop individual reports
         if (empty($this->reportPeriodsToKeep) && !$this->keepSegmentReports) {
             Piwik_DropTables($oldBlobTables);
         } else {
             foreach ($oldBlobTables as $table) {
                 $where = $this->getBlobTableWhereExpr($oldNumericTables, $table);
                 if (!empty($where)) {
                     $where = "WHERE {$where}";
                 }
                 Piwik_DeleteAllRows($table, $where, $this->maxRowsToDeletePerQuery);
             }
             if ($optimize) {
                 Piwik_OptimizeTables($oldBlobTables);
             }
         }
     }
     // deal with numeric tables
     if (!empty($oldNumericTables)) {
         // if keep_basic_metrics is set, empty all numeric tables of metrics to purge
         if ($this->keepBasicMetrics == 1 && !empty($this->metricsToKeep)) {
             $where = "WHERE name NOT IN ('" . implode("','", $this->metricsToKeep) . "') AND name NOT LIKE 'done%'";
             foreach ($oldNumericTables as $table) {
                 Piwik_DeleteAllRows($table, $where, $this->maxRowsToDeletePerQuery);
             }
             if ($optimize) {
                 Piwik_OptimizeTables($oldNumericTables);
             }
         } else {
             Piwik_DropTables($oldNumericTables);
         }
     }
 }
Example #3
0
 /**
  * @throws Exception if non-recoverable error
  */
 public function uninstall()
 {
     Piwik_DropTables(Piwik_Common::prefixTable('user_language'));
 }