File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -340,6 +340,33 @@ protected function migration19($sqlite)
340340 return $ ok ;
341341 }
342342
343+ /**
344+ * Executes Migration 20
345+ *
346+ * Adds indexes on "latest" and "published".
347+ * Those fields are not part of (autoindexed) primary key, but are used in many queries.
348+ *
349+ * @param SQLiteDB $sqlite
350+ * @return bool
351+ */
352+ protected function migration20 ($ sqlite )
353+ {
354+ $ ok = true ;
355+
356+ /** @noinspection SqlResolve */
357+ $ sql = "SELECT name FROM sqlite_master WHERE type = 'table' AND (name LIKE 'data_%' OR name LIKE 'multi_%') " ;
358+ $ tables = $ sqlite ->queryAll ($ sql );
359+
360+ foreach ($ tables as $ row ) {
361+ $ table = $ row ['name ' ]; // no escaping needed, it's our own tables
362+ $ sql = "CREATE INDEX idx_ $ table " . "_latest ON $ table(latest); " ;
363+ $ ok = $ ok && $ sqlite ->query ($ sql );
364+ $ sql = "CREATE INDEX idx_ $ table " . "_published ON $ table(published); " ;
365+ $ ok = $ ok && $ sqlite ->query ($ sql );
366+ }
367+ return $ ok ;
368+ }
369+
343370
344371 /**
345372 * Returns a select statement to fetch Lookup columns in the current schema
Original file line number Diff line number Diff line change 1- 19
1+ 20
Original file line number Diff line number Diff line change 1+ -- this migration is handled in action/migrations.php in migration20()
2+ --
3+ -- it adds indexes on fields that are not automatically indexed (latest, published)
You can’t perform that action at this time.
0 commit comments