cleanup abook structure

This commit is contained in:
friendica 2012-10-19 17:21:19 -07:00
parent 112e4e6c9c
commit 244ad5071d
2 changed files with 34 additions and 23 deletions

View file

@ -7,19 +7,30 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `abook` ( CREATE TABLE IF NOT EXISTS `abook` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `abook_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`account` int(10) unsigned NOT NULL, `abook_account` int(10) unsigned NOT NULL,
`channel` int(10) unsigned NOT NULL, `abook_channel` int(10) unsigned NOT NULL,
`xchan` char(255) NOT NULL DEFAULT '', `abook_xchan` char(255) NOT NULL DEFAULT '',
`my_perms` int(11) NOT NULL DEFAULT '0', `abook_my_perms` int(11) NOT NULL DEFAULT '0',
`their_perms` int(11) NOT NULL DEFAULT '0', `abook_their_perms` int(11) NOT NULL DEFAULT '0',
`closeness` tinyint(3) unsigned NOT NULL DEFAULT '255', `abook_closeness` tinyint(3) unsigned NOT NULL DEFAULT '255',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `abook_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `abook_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`connnected` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `abook_connnected` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`abook_flags` int(11) NOT NULL DEFAULT '0', `abook_flags` int(11) NOT NULL DEFAULT '0',
`abook_profile` char(64) NOT NULL DEFAULT '', `abook_profile` char(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`abook_id`),
KEY `abook_account` (`abook_account`),
KEY `abook_channel` (`abook_channel`),
KEY `abook_xchan` (`abook_xchan`),
KEY `abook_my_perms` (`abook_my_perms`),
KEY `abook_their_perms` (`abook_their_perms`),
KEY `abook_closeness` (`abook_closeness`),
KEY `abook_created` (`abook_created`),
KEY `abook_updated` (`abook_updated`),
KEY `abook_connnected` (`abook_connnected`),
KEY `abook_flags` (`abook_flags`),
KEY `abook_profile` (`abook_profile`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `account` ( CREATE TABLE IF NOT EXISTS `account` (

View file

@ -426,13 +426,13 @@ function profiles_content(&$a) {
// move every contact using this profile as their default to the user default // move every contact using this profile as their default to the user default
$r = q("UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND `uid` = %d ", $r = q("UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ",
intval(local_user()), intval(local_user()),
dbesc($profile_guid), dbesc($profile_guid),
intval(local_user()) intval(local_user())
); );
$r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]), intval(argv(2)),
intval(local_user()) intval(local_user())
); );
if($r) if($r)