3 define( 'UPDATE_VERSION' , 1154 );
7 * update.php - automatic system update
9 * Automatically update database schemas and any other development changes such that
10 * copying the latest files from the source code repository will always perform a clean
11 * and painless upgrade.
13 * Each function in this file is named update_nnnn() where nnnn is an increasing number
14 * which began counting at 1000.
16 * At the top of the file "boot.php" is a define for DB_UPDATE_VERSION. Any time there is a change
17 * to the database schema or one which requires an upgrade path from the existing application,
18 * the DB_UPDATE_VERSION and the UPDATE_VERSION at the top of this file are incremented.
20 * The current DB_UPDATE_VERSION is stored in the config area of the database. If the application starts up
21 * and DB_UPDATE_VERSION is greater than the last stored build number, we will process every update function
22 * in order from the currently stored value to the new DB_UPDATE_VERSION. This is expected to bring the system
23 * up to current without requiring re-installation or manual intervention.
25 * Once the upgrade functions have completed, the current DB_UPDATE_VERSION is stored as the current value.
26 * The DB_UPDATE_VERSION will always be one greater than the last numbered script in this file.
28 * If you change the database schema, the following are required:
29 * 1. Update the file database.sql to match the new schema.
30 * 2. Update this file by adding a new function at the end with the number of the current DB_UPDATE_VERSION.
31 * This function should modify the current database schema and perform any other steps necessary
32 * to ensure that upgrade is silent and free from requiring interaction.
33 * 3. Increment the DB_UPDATE_VERSION in boot.php *AND* the UPDATE_VERSION in this file to match it
34 * 4. TEST the upgrade prior to checkin and filing a pull request.
40 function update_1000() {
42 q("ALTER TABLE `item` DROP `like`, DROP `dislike` ");
44 q("ALTER TABLE `item` ADD `verb` CHAR( 255 ) NOT NULL AFTER `body` ,
45 ADD `object-type` CHAR( 255 ) NOT NULL AFTER `verb` ,
46 ADD `object` TEXT NOT NULL AFTER `object-type` ");
48 q("ALTER TABLE `intro` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `knowyou` ");
49 q("ALTER TABLE `contact` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rel` ");
50 q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
51 q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `avatar-date`");
54 function update_1001() {
55 q("ALTER TABLE `item` ADD `wall` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `type` ");
56 q("ALTER TABLE `item` ADD INDEX ( `wall` )");
59 function update_1002() {
60 q("ALTER TABLE `item` ADD `gravity` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `wall` ");
63 function update_1003() {
64 q("ALTER TABLE `contact` DROP `issued-pubkey` , DROP `ret-id` , DROP `ret-pubkey` ");
65 q("ALTER TABLE `contact` ADD `usehub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `ret-aes`");
66 q("ALTER TABLE `contact` ADD `hub-verify` CHAR( 255 ) NOT NULL AFTER `usehub`");
67 q("ALTER TABLE `contact` ADD INDEX ( `uid` ) , ADD INDEX ( `self` ), ADD INDEX ( `issued-id` ), ADD INDEX ( `dfrn-id` )");
68 q("ALTER TABLE `contact` ADD INDEX ( `blocked` ), ADD INDEX ( `readonly` )");
71 function update_1004() {
72 q("ALTER TABLE `contact` ADD `subhub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `usehub`");
75 function update_1005() {
77 q("ALTER TABLE `user` ADD `spubkey` TEXT NOT NULL AFTER `prvkey` ,
78 ADD `sprvkey` TEXT NOT NULL AFTER `spubkey`");
82 function update_1006() {
84 // create 's' keys for everybody that does not have one
86 $r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
89 $sres=openssl_pkey_new(array('encrypt_key' => false ));
91 openssl_pkey_export($sres, $sprvkey);
92 $spkey = openssl_pkey_get_details($sres);
93 $spubkey = $spkey["key"];
94 $r = q("UPDATE `user` SET `spubkey` = '%s', `sprvkey` = '%s'
95 WHERE `uid` = %d LIMIT 1",
104 function update_1007() {
105 q("ALTER TABLE `user` ADD `page-flags` INT NOT NULL DEFAULT '0' AFTER `notify-flags`");
106 q("ALTER TABLE `user` ADD INDEX ( `nickname` )");
109 function update_1008() {
110 q("ALTER TABLE `profile` ADD `with` TEXT NOT NULL AFTER `marital` ");
113 function update_1009() {
114 q("ALTER TABLE `user` ADD `allow_location` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `default-location` ");
117 function update_1010() {
118 q("ALTER TABLE `contact` ADD `lrdd` CHAR( 255 ) NOT NULL AFTER `url` ");
121 function update_1011() {
122 q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
123 $r = q("SELECT * FROM `contact` WHERE 1");
126 q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d LIMIT 1",
127 dbesc(basename($rr['url'])),
134 function update_1012() {
135 q("ALTER TABLE `item` ADD `inform` MEDIUMTEXT NOT NULL AFTER `tag` ");
138 function update_1013() {
139 q("ALTER TABLE `item` ADD `target-type` CHAR( 255 ) NOT NULL
140 AFTER `object` , ADD `target` TEXT NOT NULL AFTER `target-type`");
143 function update_1014() {
144 require_once('include/Photo.php');
145 q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
146 $r = q("SELECT * FROM `photo` WHERE `scale` = 4");
149 $ph = new Photo($rr['data']);
150 if($ph->is_valid()) {
152 $ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0));
156 $r = q("SELECT * FROM `contact` WHERE 1");
159 if(stristr($rr['thumb'],'avatar'))
160 q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1",
161 dbesc(str_replace('avatar','micro',$rr['thumb'])),
164 q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1",
165 dbesc(str_replace('5.jpg','6.jpg',$rr['thumb'])),
171 function update_1015() {
172 q("ALTER TABLE `item` CHANGE `body` `body` mediumtext NOT NULL");
175 function update_1016() {
176 q("ALTER TABLE `user` ADD `openid` CHAR( 255 ) NOT NULL AFTER `email` ");
179 function update_1017() {
181 q(" CREATE TABLE IF NOT EXISTS `clients` (
182 `client_id` VARCHAR( 20 ) NOT NULL ,
183 `pw` VARCHAR( 20 ) NOT NULL ,
184 `redirect_uri` VARCHAR( 200 ) NOT NULL ,
185 PRIMARY KEY ( `client_id` )
186 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
188 q(" CREATE TABLE IF NOT EXISTS `tokens` (
189 `id` VARCHAR( 40 ) NOT NULL ,
190 `client_id` VARCHAR( 20 ) NOT NULL ,
191 `expires` INT NOT NULL ,
192 `scope` VARCHAR( 200 ) NOT NULL ,
194 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
196 q("CREATE TABLE IF NOT EXISTS `auth_codes` (
197 `id` VARCHAR( 40 ) NOT NULL ,
198 `client_id` VARCHAR( 20 ) NOT NULL ,
199 `redirect_uri` VARCHAR( 200 ) NOT NULL ,
200 `expires` INT NOT NULL ,
201 `scope` VARCHAR( 250 ) NOT NULL ,
203 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
207 function update_1018() {
208 q("CREATE TABLE IF NOT EXISTS `queue` (
209 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
211 `created` DATETIME NOT NULL ,
212 `last` DATETIME NOT NULL ,
213 `content` MEDIUMTEXT NOT NULL
214 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
217 function update_1019() {
218 q("ALTER TABLE `mail` DROP `delivered`");
219 q("ALTER TABLE `profile` ADD `showwith` TINYINT(1) NOT NULL DEFAULT '0' AFTER `marital` ");
222 function update_1020() {
223 q("ALTER TABLE `profile` DROP `showwith`");
224 q("ALTER TABLE `item` ADD `thr-parent` CHAR( 255 ) NOT NULL AFTER `parent-uri` ");
227 function update_1021() {
228 q("ALTER TABLE `profile_check` ADD `sec` CHAR( 255 ) NOT NULL AFTER `dfrn_id` ");
229 q("ALTER TABLE `profile_check` ADD `cid` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `uid`");
230 q("ALTER TABLE `item` ADD `private` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `deny_gid` ");
233 function update_1022() {
234 q("CREATE TABLE `pconfig` (
235 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
236 `uid` INT NOT NULL DEFAULT '0',
237 `cat` CHAR( 255 ) NOT NULL ,
238 `k` CHAR( 255 ) NOT NULL ,
239 `v` MEDIUMTEXT NOT NULL
240 ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci ");
243 function update_1023() {
244 q("ALTER TABLE `user` ADD `register_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `timezone` ,
245 ADD `login_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `register_date` ");
248 function update_1024() {
249 q("ALTER TABLE `profile` ADD `keywords` TEXT NOT NULL AFTER `religion` ");
252 function update_1025() {
253 q("ALTER TABLE `user` ADD `maxreq` int(11) NOT NULL DEFAULT '10' AFTER `pwdreset` ");
256 function update_1026() {
257 q("CREATE TABLE IF NOT EXISTS `hook` (
258 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
259 `hook` CHAR( 255 ) NOT NULL ,
260 `file` CHAR( 255 ) NOT NULL ,
261 `function` CHAR( 255 ) NOT NULL
262 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
266 function update_1027() {
267 q("CREATE TABLE IF NOT EXISTS `addon` (
268 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
269 `name` CHAR( 255 ) NOT NULL ,
270 `version` CHAR( 255 ) NOT NULL ,
271 `installed` TINYINT( 1 ) NOT NULL DEFAULT '0'
272 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
275 function update_1028() {
276 q("ALTER TABLE `user` ADD `openidserver` text NOT NULL AFTER `deny_gid` ");
279 function update_1029() {
280 q("ALTER TABLE `contact` ADD `info` MEDIUMTEXT NOT NULL AFTER `reason` ");
283 function update_1030() {
284 q("ALTER TABLE `contact` ADD `bdyear` CHAR( 4 ) NOT NULL COMMENT 'birthday notify flag' AFTER `profile-id` ");
286 q("CREATE TABLE IF NOT EXISTS `event` (
287 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
290 `created` DATETIME NOT NULL ,
291 `edited` DATETIME NOT NULL ,
292 `start` DATETIME NOT NULL ,
293 `finish` DATETIME NOT NULL ,
294 `desc` TEXT NOT NULL ,
295 `location` TEXT NOT NULL ,
296 `type` CHAR( 255 ) NOT NULL ,
297 `adjust` TINYINT( 1 ) NOT NULL DEFAULT '1',
298 `allow_cid` MEDIUMTEXT NOT NULL ,
299 `allow_gid` MEDIUMTEXT NOT NULL ,
300 `deny_cid` MEDIUMTEXT NOT NULL ,
301 `deny_gid` MEDIUMTEXT NOT NULL
302 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
307 function update_1031() {
308 // Repair any bad links that slipped into the item table
309 $r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
310 if($r && count($r)) {
312 if(strstr($rr['object'],'type="http')) {
313 q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d LIMIT 1",
314 dbesc(str_replace('type="http','href="http',$rr['object'])),
322 function update_1032() {
323 q("ALTER TABLE `profile` ADD `pdesc` CHAR( 255 ) NOT NULL AFTER `name` ");
326 function update_1033() {
327 q("CREATE TABLE IF NOT EXISTS `cache` (
328 `k` CHAR( 255 ) NOT NULL PRIMARY KEY ,
330 `updated` DATETIME NOT NULL
331 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
335 function update_1034() {
337 // If you have any of these parent-less posts they can cause problems, and
338 // we need to delete them. You can't see them anyway.
339 // Legitimate items will usually get re-created on the next
340 // pull from the hub.
341 // But don't get rid of a post that may have just come in
342 // and may not yet have the parent id set.
344 q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE");
349 function update_1035() {
351 q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `last-update` ");
355 function update_1036() {
357 $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
360 q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d LIMIT 1",
361 dbesc(str_replace('include/photo','photo',$rr['photo'])),
362 dbesc(str_replace('include/photo','photo',$rr['thumb'])),
363 dbesc(str_replace('include/photo','photo',$rr['micro'])),
369 function update_1037() {
371 q("ALTER TABLE `contact` CHANGE `lrdd` `alias` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ");
375 function update_1038() {
376 q("ALTER TABLE `item` ADD `plink` CHAR( 255 ) NOT NULL AFTER `target` ");
379 function update_1039() {
380 q("ALTER TABLE `addon` ADD `timestamp` BIGINT NOT NULL DEFAULT '0'");
384 function update_1040() {
386 q("CREATE TABLE IF NOT EXISTS `fcontact` (
387 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
388 `url` CHAR( 255 ) NOT NULL ,
389 `name` CHAR( 255 ) NOT NULL ,
390 `photo` CHAR( 255 ) NOT NULL
391 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
393 q("CREATE TABLE IF NOT EXISTS `ffinder` (
394 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
395 `uid` INT UNSIGNED NOT NULL ,
396 `cid` INT UNSIGNED NOT NULL ,
397 `fid` INT UNSIGNED NOT NULL
398 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
402 function update_1041() {
403 q("ALTER TABLE `profile` CHANGE `keywords` `prv_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ");
404 q("ALTER TABLE `profile` ADD `pub_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `religion` ");
407 function update_1042() {
408 q("ALTER TABLE `user` ADD `expire` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `maxreq` ");
412 function update_1043() {
413 q("ALTER TABLE `user` ADD `blockwall` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `blocked` ");
416 function update_1044() {
417 q("ALTER TABLE `profile` ADD FULLTEXT ( `pub_keywords` ) ");
418 q("ALTER TABLE `profile` ADD FULLTEXT ( `prv_keywords` ) ");
421 function update_1045() {
422 q("ALTER TABLE `user` ADD `language` CHAR( 16 ) NOT NULL DEFAULT 'en' AFTER `timezone` ");
425 function update_1046() {
426 q("ALTER TABLE `item` ADD `attach` MEDIUMTEXT NOT NULL AFTER `tag` ");
429 function update_1047() {
430 q("ALTER TABLE `contact` ADD `writable` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `readonly` ");
433 function update_1048() {
434 q("UPDATE `contact` SET `writable` = 1 WHERE `network` = 'stat' AND `notify` != '' ");
437 function update_1049() {
438 q("CREATE TABLE `mailacct` (
439 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
441 `server` CHAR( 255 ) NOT NULL ,
442 `user` CHAR( 255 ) NOT NULL ,
443 `pass` CHAR( 255 ) NOT NULL ,
444 `reply_to` CHAR( 255 ) NOT NULL ,
445 `last_check` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
446 ) ENGINE = MYISAM ");
449 function update_1050() {
450 q("CREATE TABLE `attach` (
451 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
453 `filetype` CHAR( 64 ) NOT NULL ,
454 `filesize` INT NOT NULL ,
455 `data` LONGBLOB NOT NULL ,
456 `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
457 `edited` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
458 `allow_cid` MEDIUMTEXT NOT NULL ,
459 `allow_gid` MEDIUMTEXT NOT NULL ,
460 `deny_cid` MEDIUMTEXT NOT NULL ,
461 `deny_gid` MEDIUMTEXT NOT NULL
462 ) ENGINE = MYISAM ");
466 function update_1051() {
467 q("ALTER TABLE `mailacct` ADD `port` INT NOT NULL AFTER `server` ,
468 ADD `ssltype` CHAR( 16 ) NOT NULL AFTER `port` ,
469 ADD `mailbox` CHAR( 255 ) NOT NULL AFTER `ssltype` ");
471 q("ALTER TABLE `contact` ADD `addr` CHAR( 255 ) NOT NULL AFTER `url` ");
474 function update_1052() {
475 q("ALTER TABLE `mailacct` CHANGE `pass` `pass` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
476 q("ALTER TABLE `mailacct` ADD `pubmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `reply_to` ");
477 q("ALTER TABLE `item` ADD `pubmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `private` ");
481 function update_1053() {
482 q("ALTER TABLE `item` ADD `extid` CHAR( 255 ) NOT NULL AFTER `parent-uri` , ADD INDEX ( `extid` ) ");
485 function update_1054() {
486 q("ALTER TABLE `register` ADD `language` CHAR( 16 ) NOT NULL AFTER `password` ");
489 function update_1055() {
490 q("ALTER TABLE `profile` ADD `hidewall` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `hide-friends` ");
493 function update_1056() {
494 q("ALTER TABLE `attach` ADD `hash` CHAR( 64 ) NOT NULL AFTER `uid` ");
497 function update_1057() {
498 q("ALTER TABLE `attach` ADD `filename` CHAR( 255 ) NOT NULL AFTER `hash` ");
501 function update_1058() {
502 q("ALTER TABLE `item` ADD `event-id` INT NOT NULL AFTER `resource-id` ");
505 function update_1059() {
506 q("ALTER TABLE `queue` ADD `network` CHAR( 32 ) NOT NULL AFTER `cid` ");
509 function update_1060() {
510 q("ALTER TABLE `event` ADD `uri` CHAR( 255 ) NOT NULL AFTER `cid` ");
513 function update_1061() {
514 q("ALTER TABLE `event` ADD `nofinish` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `type` ");
517 function update_1062() {
518 q("ALTER TABLE `user` ADD `prvnets` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `page-flags` ");
520 function update_1063() {
521 q("ALTER TABLE `addon` ADD `plugin_admin` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `timestamp` ");
524 function update_1064() {
525 q("ALTER TABLE `item` ADD `app` CHAR( 255 ) NOT NULL AFTER `body` ");
528 function update_1065() {
529 q("ALTER TABLE `intro` ADD `fid` INT NOT NULL DEFAULT '0' AFTER `uid`");
532 function update_1066() {
533 $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
535 q("ALTER TABLE `item` ADD INDEX ( `received` ) ");
537 $r = q("UPDATE `item` SET `received` = `edited` WHERE 1");
540 function update_1067() {
541 q("ALTER TABLE `ffinder` ADD `type` CHAR( 16 ) NOT NULL AFTER `id` ,
542 ADD `note` TEXT NOT NULL AFTER `type` ");
545 function update_1068() {
546 // 1067 was short-sighted. Undo it.
547 q("ALTER TABLE `ffinder` DROP `type` , DROP `note` ");
549 // and do this instead.
551 q("CREATE TABLE IF NOT EXISTS `fsuggest` (
552 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
555 `name` CHAR( 255 ) NOT NULL ,
556 `url` CHAR( 255 ) NOT NULL ,
557 `photo` CHAR( 255 ) NOT NULL ,
558 `note` TEXT NOT NULL ,
559 `created` DATETIME NOT NULL
560 ) ENGINE = MYISAM DEFAULT CHARSET=utf8");
564 function update_1069() {
565 q("ALTER TABLE `fsuggest` ADD `request` CHAR( 255 ) NOT NULL AFTER `url` ");
566 q("ALTER TABLE `fcontact` ADD `request` CHAR( 255 ) NOT NULL AFTER `photo` ");
569 // mail body needs to accomodate private photos
571 function update_1070() {
572 q("ALTER TABLE `mail` CHANGE `body` `body` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ");
575 function update_1071() {
576 q("ALTER TABLE `photo` ADD INDEX ( `uid` ) ");
577 q("ALTER TABLE `photo` ADD INDEX ( `resource-id` ) ");
578 q("ALTER TABLE `photo` ADD INDEX ( `album` ) ");
579 q("ALTER TABLE `photo` ADD INDEX ( `scale` ) ");
580 q("ALTER TABLE `photo` ADD INDEX ( `profile` ) ");
584 function update_1072() {
585 q("ALTER TABLE `item` ADD `starred` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `visible` ");
586 q("ALTER TABLE `item` ADD INDEX ( `starred` ) ");
589 function update_1073() {
590 q("ALTER TABLE `contact` ADD `remote_self` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `self` ");
593 function update_1074() {
594 q("ALTER TABLE `user` ADD `hidewall` TINYINT( 1) NOT NULL DEFAULT '0' AFTER `blockwall` ");
595 $r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1");
598 q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d LIMIT 1",
602 q("ALTER TABLE `profile` DROP `hidewall`");
605 function update_1075() {
606 q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
607 $r = q("SELECT `uid` FROM `user` WHERE 1");
612 $guid = substr(random_string(),0,16);
613 $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
618 } while ($found == true );
620 q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d LIMIT 1",
628 function update_1076() {
629 q("CREATE TABLE `guid` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
630 `guid` CHAR( 16 ) NOT NULL , INDEX ( `guid` ) ) ENGINE = MYISAM ");
634 // There was a typo in 1076 so we'll try again in 1077 to make sure
635 // We'll also make it big enough to allow for future growth, I seriously
636 // doubt Diaspora will be able to leave guids at 16 bytes,
637 // and we can also use the same structure for our own larger guids
639 function update_1077() {
640 q("CREATE TABLE IF NOT EXISTS `guid` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
641 `guid` CHAR( 16 ) NOT NULL , INDEX ( `guid` ) ) ENGINE = MYISAM ");
643 q("ALTER TABLE `guid` CHANGE `guid` `guid` CHAR( 64 ) NOT NULL");
646 function update_1078() {
647 q("ALTER TABLE `item` ADD `guid` CHAR( 64 ) NOT NULL AFTER `id` , ADD INDEX ( `guid` ) ");
650 function update_1079() {
651 q("CREATE TABLE IF NOT EXISTS `sign` (
652 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
653 `iid` INT UNSIGNED NOT NULL ,
654 `signed_text` MEDIUMTEXT NOT NULL ,
655 `signature` TEXT NOT NULL ,
656 `signer` CHAR( 255 ) NOT NULL ,
658 ) ENGINE = MYISAM ");
660 q("ALTER TABLE `fcontact` ADD `nick` CHAR( 255 ) NOT NULL ,
661 ADD `addr` CHAR( 255 ) NOT NULL ,
662 ADD `notify` CHAR( 255 ) NOT NULL ,
663 ADD `poll` CHAR( 255 ) NOT NULL ,
664 ADD `confirm` CHAR( 255 ) NOT NULL ,
665 ADD `priority` TINYINT( 1 ) NOT NULL ,
666 ADD `network` CHAR( 32 ) NOT NULL ,
667 ADD `alias` CHAR( 255 ) NOT NULL ,
668 ADD `pubkey` TEXT NOT NULL ,
669 ADD INDEX ( `addr` ) ,
670 ADD INDEX ( `network` ) ");
674 function update_1080() {
675 q("ALTER TABLE `fcontact` ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
678 function update_1081() {
679 // there was a typo in update 1081 so it was corrected and moved up to 1082
682 function update_1082() {
683 q("ALTER TABLE `photo` ADD `guid` CHAR( 64 ) NOT NULL AFTER `contact-id`,
684 ADD INDEX ( `guid` ) ");
685 // make certain the following code is only executed once
686 $r = q("select `id` from `photo` where `guid` != '' limit 1");
689 $r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
693 q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
695 dbesc($rr['resource-id'])
701 function update_1083() {
702 q("CREATE TABLE IF NOT EXISTS `deliverq` (
703 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
704 `cmd` CHAR( 32 ) NOT NULL ,
705 `item` INT NOT NULL ,
706 `contact` INT NOT NULL
707 ) ENGINE = MYISAM ");
711 function update_1084() {
712 q("ALTER TABLE `contact` ADD `attag` CHAR( 255 ) NOT NULL AFTER `nick` ");
715 function update_1085() {
716 q("CREATE TABLE IF NOT EXISTS `search` (
717 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
719 `term` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
722 ) ENGINE = MYISAM ");
725 function update_1086() {
726 q("ALTER TABLE `item` ADD `bookmark` tinyint(1) NOT NULL DEFAULT '0' AFTER `starred` ");
729 function update_1087() {
730 q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
732 $r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
735 $x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
739 q("UPDATE `item` SET `commented` = '%s' WHERE `id` = %d LIMIT 1",
740 dbesc($x[0]['cdate']),
747 function update_1088() {
748 q("ALTER TABLE `user` ADD `account_expired` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `expire` ,
749 ADD `account_expires_on` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `account_expired` ,
750 ADD `expire_notification_sent` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `account_expires_on` ");
753 function update_1089() {
754 q("ALTER TABLE `user` ADD `blocktags` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `hidewall` ");
757 function update_1090() {
758 q("ALTER TABLE `contact` ADD `batch` char(255) NOT NULL AFTER `prvkey` ");
760 q("UPDATE `contact` SET `batch` = concat(substring_index(`url`,'/',3),'/receive/public') WHERE `network` = 'dspr' ");
764 function update_1091() {
766 // catch a few stragglers that may have crept in before we added this on remote connects
767 q("UPDATE `contact` SET `batch` = concat(substring_index(`url`,'/',3),'/receive/public') WHERE `network` = 'dspr' AND `batch` = '' ");
768 q("ALTER TABLE `queue` ADD `batch` TINYINT( 1 ) NOT NULL DEFAULT '0' ");
769 q("ALTER TABLE `fcontact` ADD `batch` char(255) NOT NULL AFTER `addr` ");
773 function update_1092() {
774 q("ALTER TABLE `user` ADD INDEX ( `login_date` ) ");
775 q("ALTER TABLE `user` ADD INDEX ( `account_expired` ) ");
778 function update_1093() {
779 q("CREATE TABLE IF NOT EXISTS `fserver` (
780 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
781 `server` CHAR( 255 ) NOT NULL ,
782 `posturl` CHAR( 255 ) NOT NULL ,
785 ) ENGINE = MYISAM ");
787 q("ALTER TABLE `group` ADD `visible` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `uid` ");
791 function update_1094() {
792 q("ALTER TABLE `item` ADD `postopts` TEXT NOT NULL AFTER `target` ");
795 function update_1095() {
796 q("ALTER TABLE `contact` ADD `bd` DATE NOT NULL AFTER `bdyear` ");
799 function update_1096() {
800 q("ALTER TABLE `item` ADD `origin` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `deleted` , ADD INDEX ( `origin` ) ");
803 function update_1097() {
804 q("ALTER TABLE `queue`
806 ADD INDEX (`created`),
808 ADD INDEX (`network`),
813 function update_1098() {
814 q("ALTER TABLE `contact`
815 ADD INDEX (`network`),
825 function update_1099() {
826 q("CREATE TABLE IF NOT EXISTS `gcontact` (
827 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
828 `name` CHAR( 255 ) NOT NULL ,
829 `url` CHAR( 255 ) NOT NULL ,
830 `nurl` CHAR( 255 ) NOT NULL ,
831 `photo` CHAR( 255 ) NOT NULL
832 ) ENGINE = MYISAM ");
834 q("CREATE TABLE IF NOT EXISTS `glink` (
835 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
839 `updated` DATETIME NOT NULL
840 ) ENGINE = MYISAM ");
842 q("ALTER TABLE `gcontact` ADD INDEX (`nurl`) ");
843 q("ALTER TABLE `glink` ADD INDEX (`cid`), ADD INDEX (`uid`), ADD INDEX (`gcid`), ADD INDEX (`updated`) ");
845 q("ALTER TABLE `contact` ADD `poco` TEXT NOT NULL AFTER `confirm` ");
849 function update_1100() {
850 q("ALTER TABLE `contact` ADD `nurl` CHAR( 255 ) NOT NULL AFTER `url` ");
851 q("alter table contact add index (`nurl`) ");
853 require_once('include/text.php');
855 $r = q("select id, url from contact where url != '' and nurl = '' ");
858 q("update contact set nurl = '%s' where id = %d limit 1",
859 dbesc(normalise_link($rr['url'])),
867 function update_1101() {
868 q("CREATE TABLE IF NOT EXISTS `gcign` (
869 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
872 ) ENGINE = MYISAM ");
874 q("ALTER TABLE `gcign` ADD INDEX (`uid`), ADD INDEX (`gcid`) ");
877 function update_1102() {
878 q("ALTER TABLE `clients` ADD `name` TEXT NULL DEFAULT NULL AFTER `redirect_uri` ");
879 q("ALTER TABLE `clients` ADD `icon` TEXT NULL DEFAULT NULL AFTER `name` ");
880 q("ALTER TABLE `clients` ADD `uid` INT NOT NULL DEFAULT 0 AFTER `icon` ");
882 q("ALTER TABLE `tokens` ADD `secret` TEXT NOT NULL AFTER `id` ");
883 q("ALTER TABLE `tokens` ADD `uid` INT NOT NULL AFTER `scope` ");
887 function update_1103() {
888 // q("ALTER TABLE `item` ADD INDEX ( `wall` ) ");
889 q("ALTER TABLE `item` ADD FULLTEXT ( `tag` ) ");
890 q("ALTER TABLE `contact` ADD INDEX ( `pending` ) ");
891 q("ALTER TABLE `user` ADD INDEX ( `hidewall` ) ");
892 q("ALTER TABLE `user` ADD INDEX ( `blockwall` ) ");
893 q("ALTER TABLE `user` ADD INDEX ( `blocked` ) ");
894 q("ALTER TABLE `user` ADD INDEX ( `verified` ) ");
898 function update_1104() {
899 q("ALTER TABLE `item` ADD `forum_mode` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `origin` , ADD INDEX ( `forum_mode` ) ");
903 function update_1105() {
904 q("ALTER TABLE `mail` ADD `convid` INT NOT NULL AFTER `contact-id` ");
905 q("ALTER TABLE `mail` ADD `guid` CHAR( 64 ) NOT NULL AFTER `uid` ");
907 q("CREATE TABLE IF NOT EXISTS `conv` (
908 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
909 `guid` CHAR( 64 ) NOT NULL ,
910 `recips` MEDIUMTEXT NOT NULL ,
912 ) ENGINE = MYISAM ");
916 function update_1106() {
917 q("ALTER TABLE `item` ADD INDEX ( `author-link` ) ");
921 function update_1107() {
922 q("ALTER TABLE `item` ADD INDEX ( `bookmark` ) ");
926 function update_1108() {
927 q("ALTER TABLE `contact` ADD `hidden` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `writable` ,
928 ADD INDEX ( `hidden` ) ");
932 function update_1109() {
933 q("ALTER TABLE `conv` ADD `creator` CHAR( 255 ) NOT NULL ,
934 ADD `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
935 ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
936 ADD `subject` MEDIUMTEXT NOT NULL,
937 ADD INDEX ( `created` ), ADD INDEX ( `updated` ) ");
940 function update_1110() {
941 q("ALTER TABLE `mail` ADD `reply` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `seen`,
942 ADD INDEX ( `reply` ), ADD INDEX ( `uid` ), ADD INDEX ( `guid` ), ADD INDEX ( `seen` ),
943 ADD INDEX ( `uri` ), ADD INDEX ( `parent-uri`), ADD INDEX ( `created` ), ADD INDEX ( `convid` ) ");
947 function update_1111() {
948 q("ALTER TABLE `gcontact` ADD `connect` CHAR( 255 ) NOT NULL ");
952 function update_1112() {
954 q("CREATE TABLE IF NOT EXISTS `notify` (
955 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
956 `type` INT( 11 ) NOT NULL ,
957 `name` CHAR( 255 ) NOT NULL ,
958 `url` CHAR( 255 ) NOT NULL ,
959 `photo` CHAR( 255 ) NOT NULL ,
960 `date` DATETIME NOT NULL ,
961 `msg` MEDIUMTEXT NOT NULL ,
963 `link` CHAR( 255 ) NOT NULL ,
964 `seen` TINYINT( 1 ) NOT NULL DEFAULT '0'
965 ) ENGINE = MYISAM ");
967 q("ALTER TABLE `notify` ADD INDEX ( `type` ), ADD INDEX ( `uid`), ADD INDEX (`seen`), ADD INDEX (`date`) ");
971 function update_1113() {
972 q("ALTER TABLE `notify` ADD `verb` CHAR( 255 ) NOT NULL ,
973 ADD `otype` CHAR( 16 ) NOT NULL");
976 function update_1114() {
977 q("CREATE TABLE IF NOT EXISTS `item_id` (
980 `face` CHAR( 255 ) NOT NULL ,
981 `dspr` CHAR( 255 ) NOT NULL ,
982 `twit` CHAR( 255 ) NOT NULL ,
983 `stat` CHAR( 255 ) NOT NULL ,
984 PRIMARY KEY ( `iid` ),
990 ) ENGINE = MYISAM ");
994 function update_1115() {
995 q("ALTER TABLE `item` ADD `moderated`
996 TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `pubmail`,
997 ADD INDEX (`moderated`) ");
1000 function update_1116() {
1001 //typo! corrected update was rolled forward
1004 function update_1117() {
1005 q("create table if not exists `manage` (
1006 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1007 `uid` INT NOT NULL ,
1011 ) ENGINE = MYISAM ");
1015 function update_1118() {
1019 function update_1119() {
1020 q("ALTER TABLE `contact` ADD `closeness` TINYINT( 2 ) NOT NULL DEFAULT '99' AFTER `reason` , ADD INDEX (`closeness`) ");
1021 q("update contact set closeness = 0 where self = 1");
1022 q("ALTER TABLE `item` ADD `spam` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `visible` , ADD INDEX (`spam`) ");
1026 function update_1120() {
1028 // item table update from 1119 did not get into database.sql file.
1029 // might be missing on new installs. We'll check.
1031 $r = q("describe item");
1032 if($r && count($r)) {
1034 if($rr['Field'] == 'spam')
1037 q("ALTER TABLE `item` ADD `spam` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `visible` , ADD INDEX (`spam`) ");
1041 function update_1121() {
1042 q("CREATE TABLE IF NOT EXISTS `poll_result` (
1043 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1044 `poll_id` INT NOT NULL ,
1045 `choice` INT NOT NULL ,
1046 INDEX ( `poll_id` ),
1048 ) ENGINE = MYISAM ");
1050 q("CREATE TABLE IF NOT EXISTS `poll` (
1051 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1052 `uid` INT NOT NULL ,
1053 `q0` MEDIUMTEXT NOT NULL ,
1054 `q1` MEDIUMTEXT NOT NULL ,
1055 `q2` MEDIUMTEXT NOT NULL ,
1056 `q3` MEDIUMTEXT NOT NULL ,
1057 `q4` MEDIUMTEXT NOT NULL ,
1058 `q5` MEDIUMTEXT NOT NULL ,
1059 `q6` MEDIUMTEXT NOT NULL ,
1060 `q7` MEDIUMTEXT NOT NULL ,
1061 `q8` MEDIUMTEXT NOT NULL ,
1062 `q9` MEDIUMTEXT NOT NULL ,
1064 ) ENGINE = MYISAM ");
1068 function update_1122() {
1069 q("ALTER TABLE `notify` ADD `hash` CHAR( 64 ) NOT NULL AFTER `id` ,
1070 ADD INDEX ( `hash` ) ");
1073 function update_1123() {
1074 set_config('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr');
1077 function update_1124() {
1078 q("alter table item add index (`author-name`) ");
1081 function update_1125() {
1082 q("CREATE TABLE IF NOT EXISTS `notify-threads` (
1083 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1084 `notify-id` INT NOT NULL,
1085 `master-parent-item` INT( 10 ) unsigned NOT NULL DEFAULT '0',
1086 `parent-item` INT( 10 ) unsigned NOT NULL DEFAULT '0',
1087 `receiver-uid` INT NOT NULL,
1088 INDEX ( `master-parent-item` ),
1089 INDEX ( `receiver-uid` )
1090 ) ENGINE = MyISAM DEFAULT CHARSET=utf8");
1093 function update_1126() {
1094 q("ALTER TABLE `mailacct` ADD `action` INT NOT NULL AFTER `pass`,
1095 ADD `movetofolder` CHAR(255) NOT NULL AFTER `action`");
1098 function update_1127() {
1099 q("CREATE TABLE IF NOT EXISTS `spam` (
1100 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1102 `spam` INT NOT NULL DEFAULT '0',
1103 `ham` INT NOT NULL DEFAULT '0',
1104 `term` CHAR(255) NOT NULL,
1109 ) ENGINE = MyISAM DEFAULT CHARSET=utf8");
1113 function update_1128() {
1114 q("alter table spam add `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `term` ");
1117 function update_1129() {
1118 q("ALTER TABLE `notify` ADD `parent` INT NOT NULL AFTER `link` , ADD INDEX ( `parent` ), ADD INDEX ( `link` ), ADD INDEX ( `otype` ) ");
1121 function update_1130() {
1122 q("ALTER TABLE `item` ADD `file` MEDIUMTEXT NOT NULL AFTER `inform`, ADD FULLTEXT KEY (`file`) ");
1125 function update_1131() {
1126 q("ALTER TABLE `contact` ADD `forum` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `writable` , ADD INDEX ( `forum` ) ");
1130 function update_1132() {
1131 q("CREATE TABLE IF NOT EXISTS `userd` (
1132 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1133 `username` CHAR( 255 ) NOT NULL,
1134 INDEX ( `username` )
1135 ) ENGINE = MYISAM ");
1139 function update_1133() {
1140 q("ALTER TABLE `user` ADD `unkmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `blocktags` , ADD INDEX ( `unkmail` ) ");
1141 q("ALTER TABLE `user` ADD `cntunkmail` INT NOT NULL DEFAULT '10' AFTER `unkmail` , ADD INDEX ( `cntunkmail` ) ");
1142 q("ALTER TABLE `mail` ADD `unknown` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `replied` , ADD INDEX ( `unknown` ) ");
1145 function update_1134() {
1146 // faulty update merged forward
1147 // had a hardwired tablename of 'friendica' which isn't the right name on most systems
1150 function update_1135() {
1151 //there can't be indexes with more than 1000 bytes in mysql,
1152 //so change charset to be smaller
1153 q("ALTER TABLE `config` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL ,
1154 CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL");
1156 //same thing for pconfig
1157 q("ALTER TABLE `pconfig` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL ,
1158 CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL");
1159 // faulty update merged forward. Bad update in 1134 caused duplicate k,cat pairs
1160 // these have to be cleared before the unique keys can be added.
1163 function update_1136() {
1167 // order in reverse so that we save the newest entry
1169 $r = q("select * from config where 1 order by id desc");
1171 foreach($r as $rr) {
1173 foreach($arr as $x) {
1174 if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
1176 q("delete from config where id = %d limit 1",
1188 $r = q("select * from pconfig where 1 order by id desc");
1190 foreach($r as $rr) {
1192 foreach($arr as $x) {
1193 if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
1195 q("delete from pconfig where id = %d limit 1",
1205 q("ALTER TABLE `config` ADD UNIQUE `access` ( `cat` , `k` ) ");
1206 q("ALTER TABLE `pconfig` ADD UNIQUE `access` ( `uid` , `cat` , `k` )");
1211 function update_1137() {
1212 q("alter table item_id DROP `face` , DROP `dspr` , DROP `twit` , DROP `stat` ");
1213 q("ALTER TABLE `item_id` ADD `sid` CHAR( 255 ) NOT NULL AFTER `uid` , ADD `service` CHAR( 255 ) NOT NULL AFTER `sid` , add index (`sid`), add index ( `service`) ");
1216 function update_1138() {
1217 q("alter table contact add archive tinyint(1) not null default '0' after hidden, add index (archive)");
1220 function update_1139() {
1221 $r = q("alter table user add account_removed tinyint(1) not null default '0' after expire, add index(account_removed) ");
1223 return UPDATE_FAILED ;
1224 return UPDATE_SUCCESS ;
1227 function update_1140() {
1228 $r = q("alter table addon add hidden tinyint(1) not null default '0' after installed, add index(hidden) ");
1230 return UPDATE_FAILED ;
1231 return UPDATE_SUCCESS ;
1234 function update_1141() {
1235 $r = q("alter table glink add zcid int(11) not null after gcid, add index(zcid) ");
1237 return UPDATE_FAILED ;
1238 return UPDATE_SUCCESS ;
1242 function update_1142() {
1243 $r = q("alter table user add service_class char(32) not null after expire_notification_sent, add index(service_class) ");
1245 return UPDATE_FAILED ;
1246 return UPDATE_SUCCESS ;
1249 function update_1143() {
1250 $r = q("alter table user add def_gid int(11) not null default '0' after service_class");
1252 return UPDATE_FAILED ;
1253 return UPDATE_SUCCESS ;
1256 function update_1144() {
1257 $r = q("alter table contact add prv tinyint(1) not null default '0' after forum");
1259 return UPDATE_FAILED ;
1260 return UPDATE_SUCCESS ;
1263 function update_1145() {
1264 $r = q("alter table profile add howlong datetime not null default '0000-00-00 00:00:00' after `with`");
1266 return UPDATE_FAILED ;
1267 return UPDATE_SUCCESS ;
1270 function update_1146() {
1271 $r = q("alter table profile add hometown char(255) not null after `country-name`, add index ( `hometown` ) ");
1273 return UPDATE_FAILED ;
1274 return UPDATE_SUCCESS ;
1277 function update_1147() {
1278 $r1 = q("ALTER TABLE `sign` ALTER `iid` SET DEFAULT '0'");
1279 $r2 = q("ALTER TABLE `sign` ADD `retract_iid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `iid`");
1280 $r3 = q("ALTER TABLE `sign` ADD INDEX ( `retract_iid` )");
1281 if((! $r1) || (! $r2) || (! $r3))
1282 return UPDATE_FAILED ;
1283 return UPDATE_SUCCESS ;
1286 function update_1148() {
1287 $r = q("ALTER TABLE photo ADD type CHAR(128) NOT NULL DEFAULT 'image/jpeg' AFTER filename");
1289 return UPDATE_FAILED;
1290 return UPDATE_SUCCESS;
1294 function update_1149() {
1295 $r1 = q("ALTER TABLE profile ADD likes text NOT NULL after prv_keywords");
1296 $r2 = q("ALTER TABLE profile ADD dislikes text NOT NULL after likes");
1298 return UPDATE_FAILED;
1299 return UPDATE_SUCCESS;
1303 function update_1150() {
1304 $r = q("ALTER TABLE event ADD summary text NOT NULL after finish, add index ( uid ), add index ( cid ), add index ( uri ), add index ( `start` ), add index ( finish ), add index ( `type` ), add index ( adjust ) ");
1306 return UPDATE_FAILED;
1307 return UPDATE_SUCCESS;
1311 function update_1151() {
1312 $r = q("CREATE TABLE IF NOT EXISTS locks (
1313 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1314 name CHAR( 128 ) NOT NULL ,
1315 locked TINYINT( 1 ) NOT NULL DEFAULT '0'
1316 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
1318 return UPDATE_FAILED;
1319 return UPDATE_SUCCESS;
1322 function update_1152() {
1323 $r = q("CREATE TABLE IF NOT EXISTS `term` (
1324 `tid` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
1325 `oid` INT UNSIGNED NOT NULL ,
1326 `otype` TINYINT( 3 ) UNSIGNED NOT NULL ,
1327 `type` TINYINT( 3 ) UNSIGNED NOT NULL ,
1328 `term` CHAR( 255 ) NOT NULL ,
1329 `url` CHAR( 255 ) NOT NULL,
1330 KEY `oid` ( `oid` ),
1331 KEY `otype` ( `otype` ),
1332 KEY `type` ( `type` ),
1333 KEY `term` ( `term` )
1334 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
1336 return UPDATE_FAILED;
1337 return UPDATE_SUCCESS;
1340 function update_1153() {
1341 $r = q("ALTER TABLE `hook` ADD `priority` INT(11) UNSIGNED NOT NULL DEFAULT '0'");
1343 if(!$r) return UPDATE_FAILED;
1344 return UPDATE_SUCCESS;