Blame view

sources/apps/search_lucene/appinfo/preupdate.php 853 Bytes
d1bafeea1   Kload   [fix] Upgrade to ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  <?php
  
  $currentVersion=OC_Appconfig::getValue('search_lucene', 'installed_version');
  
  if (version_compare($currentVersion, '0.5.2', '<')) {
  	
  	//delete duplicate id entries
  	
  	$dbtype = \OCP\Config::getSystemValue('dbtype', 'sqlite3');
  	
  	if ($dbtype === 'mysql') {
  		// fix MySQL ERROR 1093 (HY000), see http://stackoverflow.com/a/12969601
  		$sql = 'DELETE FROM `*PREFIX*lucene_status`
  				WHERE `fileid` IN (
  					SELECT `fileid` FROM (
  						SELECT `fileid`
  						FROM `*PREFIX*lucene_status`
  						GROUP BY `fileid`
  						HAVING count(`status`) > 1
  					) AS `mysqlerr1093hack`
  				)
  			';
  	} else {
  		$sql = 'DELETE FROM `*PREFIX*lucene_status`
  				WHERE `fileid` IN (
  					SELECT `fileid`
  					FROM `*PREFIX*lucene_status`
  					GROUP BY `fileid`
  					HAVING count(`status`) > 1
  				)
  			';
  	}
  	
  	$stmt = OCP\DB::prepare($sql);
  	$stmt->execute();
  }