mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-07-25 16:01:54 +00:00
DB migration: add indexes for latest and published
This commit is contained in:
@ -340,6 +340,33 @@ class action_plugin_struct_migration extends ActionPlugin
|
|||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes Migration 20
|
||||||
|
*
|
||||||
|
* Adds indexes on "latest" and "published".
|
||||||
|
* Those fields are not part of (autoindexed) primary key, but are used in many queries.
|
||||||
|
*
|
||||||
|
* @param SQLiteDB $sqlite
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function migration20($sqlite)
|
||||||
|
{
|
||||||
|
$ok = true;
|
||||||
|
|
||||||
|
/** @noinspection SqlResolve */
|
||||||
|
$sql = "SELECT name FROM sqlite_master WHERE type = 'table' AND (name LIKE 'data_%' OR name LIKE 'multi_%')";
|
||||||
|
$tables = $sqlite->queryAll($sql);
|
||||||
|
|
||||||
|
foreach ($tables as $row) {
|
||||||
|
$table = $row['name']; // no escaping needed, it's our own tables
|
||||||
|
$sql = "CREATE INDEX idx_$table" . "_latest ON $table(latest);";
|
||||||
|
$ok = $ok && $sqlite->query($sql);
|
||||||
|
$sql = "CREATE INDEX idx_$table" . "_published ON $table(published);";
|
||||||
|
$ok = $ok && $sqlite->query($sql);
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a select statement to fetch Lookup columns in the current schema
|
* Returns a select statement to fetch Lookup columns in the current schema
|
||||||
|
@ -1 +1 @@
|
|||||||
19
|
20
|
||||||
|
3
db/update0020.sql
Normal file
3
db/update0020.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
-- this migration is handled in action/migrations.php in migration20()
|
||||||
|
--
|
||||||
|
-- it adds indexes on fields that are not automatically indexed (latest, published)
|
Reference in New Issue
Block a user