define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '2.3.1303' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1136 );
+define ( 'DB_UPDATE_VERSION', 1137 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
<?php
-define( 'UPDATE_VERSION' , 1136 );
+define( 'UPDATE_VERSION' , 1137 );
/**
*
//so change charset to be smaller
q("ALTER TABLE `config` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL ,
CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL");
- //and add the index
- q("ALTER TABLE `config` ADD UNIQUE `access` ( `cat` , `k` ) ");
//same thing for pconfig
q("ALTER TABLE `pconfig` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL ,
CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL");
-
+ // faulty update merged forward. Bad update in 1134 caused duplicate k,cat pairs
+ // these have to be cleared before the unique keys can be added.
+}
+
+function update_1136() {
+
+ $arr = array();
+
+ // order in reverse so that we save the newest entry
+
+ $r = q("select * from config where 1 order by id desc");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $found = false;
+ foreach($arr as $x) {
+ if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
+ $found = true;
+ q("delete from config where id = %d limit 1",
+ intval($rr['id'])
+ );
+ }
+ }
+ if(! $found) {
+ $arr[] = $rr;
+ }
+ }
+ }
+
+ $arr = array();
+ $r = q("select * from pconfig where 1 order by id desc");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $found = false;
+ foreach($arr as $x) {
+ if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
+ $found = true;
+ q("delete from pconfig where id = %d limit 1",
+ intval($rr['id'])
+ );
+ }
+ }
+ if(! $found) {
+ $arr[] = $rr;
+ }
+ }
+ }
+ q("ALTER TABLE `config` ADD UNIQUE `access` ( `cat` , `k` ) ");
q("ALTER TABLE `pconfig` ADD UNIQUE `access` ( `uid` , `cat` , `k` )");
+
}
\ No newline at end of file