change the likes db structure to make it more easily importable/exportable

This commit is contained in:
redmatrix 2015-08-31 20:55:25 -07:00
parent 96c61fc5f2
commit d7cf7316be
8 changed files with 282 additions and 258 deletions

View File

@ -49,7 +49,7 @@ define ( 'PLATFORM_NAME', 'redmatrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1148 );
define ( 'DB_UPDATE_VERSION', 1149 );
/**
* @brief Constant with a HTML line break.

View File

@ -565,7 +565,7 @@ function identity_basic_export($channel_id, $items = false) {
if(! $items)
return $ret;
$r = q("select likes.*, item.mid from likes left join item on likes.iid = item.id where likes.channel_id = %d",
$r = q("select * likes where channel_id = %d",
intval($channel_id)
);

View File

@ -772,6 +772,7 @@ CREATE TABLE IF NOT EXISTS `likes` (
`liker` char(128) NOT NULL DEFAULT '',
`likee` char(128) NOT NULL DEFAULT '',
`iid` int(11) unsigned NOT NULL DEFAULT '0',
`i_mid` char(255) NOT NULL DEFAULT '',
`verb` char(255) NOT NULL DEFAULT '',
`target_type` char(255) NOT NULL DEFAULT '',
`target_id` char(128) NOT NULL DEFAULT '',
@ -780,6 +781,7 @@ CREATE TABLE IF NOT EXISTS `likes` (
KEY `liker` (`liker`),
KEY `likee` (`likee`),
KEY `iid` (`iid`),
KEY `i_mid` (`i_mid`),
KEY `verb` (`verb`),
KEY `target_type` (`target_type`),
KEY `channel_id` (`channel_id`),

View File

@ -602,6 +602,7 @@ CREATE TABLE "likes" (
"liker" char(128) NOT NULL DEFAULT '',
"likee" char(128) NOT NULL DEFAULT '',
"iid" bigint NOT NULL DEFAULT '0',
"i_mid" char(255) NOT NULL DEFAULT '',
"verb" text NOT NULL DEFAULT '',
"target_type" text NOT NULL DEFAULT '',
"target_id" char(128) NOT NULL DEFAULT '',
@ -612,6 +613,7 @@ create index "likes_channel_id" on likes ("channel_id");
create index "likes_liker" on likes ("liker");
create index "likes_likee" on likes ("likee");
create index "likes_iid" on likes ("iid");
create index "likes_i_mid" on likes ("i_mid");
create index "likes_verb" on likes ("verb");
create index "likes_target_type" on likes ("target_type");
create index "likes_target_id" on likes ("target_id");

View File

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1148 );
define( 'UPDATE_VERSION' , 1149 );
/**
*
@ -1714,3 +1714,22 @@ function update_r1147() {
return UPDATE_FAILED;
}
function update_r1148() {
$r1 = q("alter table likes add i_mid char(255) not null default '' ");
$r2 = q("create index i_mid on likes ( i_mid ) ");
$r3 = q("select likes.*, item.mid from from likes left join item on likes.iid = item.id");
if($r3) {
foreach($r3 as $rr) {
q("update likes set i_mid = '%s' where id = $d",
dbesc($rr['mid']),
intval($rr['id'])
);
}
}
if($r1 && $r2)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}

View File

@ -473,11 +473,12 @@ function like_content(&$a) {
if($extended_like) {
$r = q("insert into likes (channel_id,liker,likee,iid,verb,target_type,target_id,target) values (%d,'%s','%s',%d,'%s','%s','%s','%s')",
$r = q("insert into likes (channel_id,liker,likee,iid,i_mid,verb,target_type,target_id,target) values (%d,'%s','%s',%d,'%s','%s','%s','%s','%s')",
intval($ch[0]['channel_id']),
dbesc($observer['xchan_hash']),
dbesc($ch[0]['channel_hash']),
intval($post_id),
dbesc($mid),
dbesc($activity),
dbesc(($tgttype)?$tgttype:$objtype),
dbesc($obj_id),

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
2015-08-27.1137
2015-08-31.1141