INDEX `url` (`url`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
+--
+-- TABLE post-category
+--
+CREATE TABLE IF NOT EXISTS `post-category` (
+ `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
+ `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
+ `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
+ `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
+ PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
+ INDEX `uri-id` (`tid`)
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
+
+ --
+ -- TABLE post-delivery-data
+ --
+ CREATE TABLE IF NOT EXISTS `post-delivery-data` (
+ `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
+ `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery',
+ `inform` mediumtext COMMENT 'Additional receivers of the linked item',
+ `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
+ `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
+ `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
+ `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
+ `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
+ `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
+ `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
+ `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
+ PRIMARY KEY(`uri-id`)
+ ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
+
--
-- TABLE post-tag
--
if (!self::update1342()) {
return false;
}
+ if (!self::update1345()) {
+ return false;
+ }
+ if (!self::update1346()) {
+ return false;
+ }
return true;
}
return false;
}
-
+ /**
+ * Fill the "post-delivery-data" table with data from the "item-delivery-data" table
+ *
+ * @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ private static function update1345()
+ {
+ // Was the script completed?
+ if (DI::config()->get('system', 'post_update_version') >= 1345) {
+ return true;
+ }
+
+ $id = DI::config()->get('system', 'post_update_version_1345_id', 0);
- }
+ Logger::info('Start', ['item' => $id]);
+
+ $rows = 0;
+
+ $deliveries = DBA::p("SELECT `uri-id`, `iid`, `item-delivery-data`.`postopts`, `item-delivery-data`.`inform`,
+ `queue_count`, `queue_done`, `activitypub`, `dfrn`, `diaspora`, `ostatus`, `legacy_dfrn`, `queue_failed`
+ FROM `item-delivery-data`
+ INNER JOIN `item` ON `item`.`id` = `item-delivery-data`.`iid`
+ WHERE `iid` >= ? ORDER BY `iid` LIMIT 10000", $id);
+
+ if (DBA::errorNo() != 0) {
+ Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
+ return false;
+ }
+
+ while ($delivery = DBA::fetch($deliveries)) {
+ $id = $delivery['iid'];
+ unset($delivery['iid']);
+ DBA::insert('post-delivery-data', $delivery);
+ ++$rows;
+ }
+ DBA::close($deliveries);
+
+ DI::config()->set('system', 'post_update_version_1345_id', $id);
+
+ Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
+
+ // When there are less than 100 items processed this means that we reached the end
+ // The other entries will then be processed with the regular functionality
+ if ($rows < 100) {
+ DI::config()->set('system', 'post_update_version', 1345);
+ Logger::info('Done');
+ return true;
+ }
+
+ return false;
+ }
++
++
++
+ /**
+ * Fill the "tag" table with tags and mentions from the "term" table
+ *
+ * @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ private static function update1346()
+ {
+ // Was the script completed?
+ if (DI::config()->get('system', 'post_update_version') >= 1346) {
+ return true;
+ }
+
+ $id = DI::config()->get('system', 'post_update_version_1346_id', 0);
+
+ Logger::info('Start', ['item' => $id]);
+
+ $rows = 0;
+
+ $terms = DBA::select('term', ['oid'],
+ ["`type` IN (?, ?) AND `oid` >= ?", Category::CATEGORY, Category::FILE, $id],
+ ['order' => ['oid'], 'limit' => 1000, 'group_by' => ['oid']]);
+
+ if (DBA::errorNo() != 0) {
+ Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
+ return false;
+ }
+
+ while ($term = DBA::fetch($terms)) {
+ $item = Item::selectFirst(['uri-id', 'uid'], ['id' => $term['oid']]);
+ if (!DBA::isResult($item)) {
+ continue;
+ }
+
+ $file = Term::fileTextFromItemId($term['oid']);
+ if (!empty($file)) {
+ Category::storeTextByURIId($item['uri-id'], $item['uid'], $file);
+ }
+
+ $id = $term['oid'];
+ ++$rows;
+ if ($rows % 100 == 0) {
+ DI::config()->set('system', 'post_update_version_1346_id', $id);
+ }
+ }
+ DBA::close($terms);
+
+ DI::config()->set('system', 'post_update_version_1346_id', $id);
+
+ Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
+
+ // When there are less than 10 items processed this means that we reached the end
+ // The other entries will then be processed with the regular functionality
+ if ($rows < 10) {
+ DI::config()->set('system', 'post_update_version', 1346);
+ Logger::info('Done');
+ return true;
+ }
+
+ return false;
++ }
}
"url" => ["url"]
]
],
+ "post-category" => [
+ "comment" => "post relation to categories",
+ "fields" => [
+ "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
+ "tid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["tag" => "id"], "comment" => ""],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uri-id", "uid", "type", "tid"],
+ "uri-id" => ["tid"]
+ ]
+ ],
+ "post-delivery-data" => [
+ "comment" => "Delivery data for items",
+ "fields" => [
+ "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
+ "postopts" => ["type" => "text", "comment" => "External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery"],
+ "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of the linked item"],
+ "queue_count" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Initial number of delivery recipients, used as item.delivery_queue_count"],
+ "queue_done" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries, used as item.delivery_queue_done"],
+ "queue_failed" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of unsuccessful deliveries, used as item.delivery_queue_failed"],
+ "activitypub" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via ActivityPub"],
+ "dfrn" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via DFRN"],
+ "legacy_dfrn" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via legacy DFRN"],
+ "diaspora" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via Diaspora"],
+ "ostatus" => ["type" => "mediumint", "not null" => "1", "default" => "0", "comment" => "Number of successful deliveries via OStatus"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uri-id"],
+ ]
+ ],
"post-tag" => [
"comment" => "post relation to tags",
"fields" => [