create url mapping table for nomadic content imports

This commit is contained in:
Mike Macgirvin 2024-07-15 07:44:54 +10:00
parent fc2c0b0149
commit 59dbd66037
4 changed files with 74 additions and 1 deletions

View file

@ -27,7 +27,7 @@ use Code\Lib\Url;
*/
const REPOSITORY_ID = 'streams';
const DB_UPDATE_VERSION = 1281;
const DB_UPDATE_VERSION = 1282;
const PROJECT_BASE = __DIR__;
const ACTIVITYPUB_ENABLED = true;
const NOMAD_PROTOCOL_VERSION = '13.3';

View file

@ -728,6 +728,16 @@ CREATE TABLE IF NOT EXISTS listeners (
KEY ltype (ltype)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS locator (
id int NOT NULL AUTO_INCREMENT,
locate_old varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
locate_new varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE KEY locate_old (locate_old(191)),
KEY locate_new (locate_new(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `menu` (
`menu_id` int unsigned NOT NULL AUTO_INCREMENT,
`menu_channel_id` int unsigned NOT NULL DEFAULT 0 ,

View file

@ -749,6 +749,16 @@ CREATE TABLE listeners (
create index "target_id_idx" on listeners ("target_id");
create index "portable_id_idx" on listeners ("portable_id");
create index "ltype_idx" on listeners ("ltype");
CREATE TABLE locator (
id serial NOT NULL,
locate_old text NOT NULL,
locate_new text NOT NULL,
PRIMARY KEY ("id"),
UNIQUE ("locate_old")
);
create index "locate_new_idx" on locator ("locate_new");
CREATE TABLE "menu" (
"menu_id" serial NOT NULL,
"menu_channel_id" bigint NOT NULL DEFAULT '0',

53
src/Update/_1282.php Normal file
View file

@ -0,0 +1,53 @@
<?php
namespace Code\Update;
class _1282
{
public function run()
{
q("START TRANSACTION");
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r1 = q('CREATE TABLE "locator" (
"id" serial NOT NULL,
"locate_old" text NOT NULL,
"locate_new" text NOT NULL,
PRIMARY KEY ("id"),
UNIQUE ("locate_old"))');
$r2 = q('create index "locate_new_idx" on locator ("locate_new")');
$r = ($r1 && $r2);
}
else {
$r = q("CREATE TABLE IF NOT EXISTS locator (
id int NOT NULL AUTO_INCREMENT,
locate_old varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
locate_new varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE KEY locate_old (locate_old(191)),
KEY locate_new (locate_new(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
}
if ($r) {
q("COMMIT");
return UPDATE_SUCCESS;
}
q("ROLLBACK");
return UPDATE_FAILED;
}
public function verify()
{
$columns = db_columns('locator');
if ($columns && in_array('locate_old', $columns)) {
return true;
}
return false;
}
}