mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:40:17 +00:00
[Database version 1402] Rework parsed_url table
- Allow arbitrary-sized URL - Use URL hash for primary key instead of truncated URL, requires table truncation pre update - Add expires field
This commit is contained in:
parent
1b90686fcd
commit
7de03eb13f
3 changed files with 23 additions and 8 deletions
12
database.sql
12
database.sql
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2021.03-dev (Red Hot Poker)
|
-- Friendica 2021.03-dev (Red Hot Poker)
|
||||||
-- DB_UPDATE_VERSION 1402
|
-- DB_UPDATE_VERSION 1403
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -959,15 +959,17 @@ CREATE TABLE IF NOT EXISTS `openwebauth-token` (
|
||||||
-- TABLE parsed_url
|
-- TABLE parsed_url
|
||||||
--
|
--
|
||||||
CREATE TABLE IF NOT EXISTS `parsed_url` (
|
CREATE TABLE IF NOT EXISTS `parsed_url` (
|
||||||
`url` varbinary(255) NOT NULL COMMENT 'page url',
|
`url_hash` binary(64) NOT NULL COMMENT 'page url hash',
|
||||||
`guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
|
`guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
|
||||||
`oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
|
`oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
|
||||||
|
`url` text NOT NULL COMMENT 'page url',
|
||||||
`content` mediumtext COMMENT 'page data',
|
`content` mediumtext COMMENT 'page data',
|
||||||
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
|
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
|
||||||
PRIMARY KEY(`url`,`guessing`,`oembed`),
|
`expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration',
|
||||||
INDEX `created` (`created`)
|
PRIMARY KEY(`url_hash`,`guessing`,`oembed`),
|
||||||
|
INDEX `created` (`created`),
|
||||||
|
INDEX `expires` (`expires`)
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
|
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
|
||||||
|
|
||||||
--
|
--
|
||||||
-- TABLE pconfig
|
-- TABLE pconfig
|
||||||
--
|
--
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1402);
|
define('DB_UPDATE_VERSION', 1403);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -1019,15 +1019,18 @@ return [
|
||||||
"parsed_url" => [
|
"parsed_url" => [
|
||||||
"comment" => "cache for 'parse_url' queries",
|
"comment" => "cache for 'parse_url' queries",
|
||||||
"fields" => [
|
"fields" => [
|
||||||
"url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
|
"url_hash" => ["type" => "binary(64)", "not null" => "1", "primary" => "1", "comment" => "page url hash"],
|
||||||
"guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"],
|
"guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"],
|
||||||
"oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"],
|
"oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"],
|
||||||
|
"url" => ["type" => "text", "not null" => "1", "comment" => "page url"],
|
||||||
"content" => ["type" => "mediumtext", "comment" => "page data"],
|
"content" => ["type" => "mediumtext", "comment" => "page data"],
|
||||||
"created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of creation"],
|
"created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of creation"],
|
||||||
|
"expires" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "datetime of expiration"],
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["url", "guessing", "oembed"],
|
"PRIMARY" => ["url_hash", "guessing", "oembed"],
|
||||||
"created" => ["created"],
|
"created" => ["created"],
|
||||||
|
"expires" => ["expires"],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pconfig" => [
|
"pconfig" => [
|
||||||
|
|
10
update.php
10
update.php
|
@ -817,3 +817,13 @@ function update_1400()
|
||||||
|
|
||||||
return Update::SUCCESS;
|
return Update::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pre_update_1403()
|
||||||
|
{
|
||||||
|
// Necessary before a primary key change
|
||||||
|
if (!DBA::e("DROP TABLE `parsed_url`")) {
|
||||||
|
return Update::FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Update::SUCCESS;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue