Add indexes to lotw_users table

Introduces migration 208 to add indexes on 'callsign' and 'lastupload' columns in the lotw_users table for improved query performance. Updates migration version to 208.
这个提交包含在:
Peter Goodhall 2025-08-22 16:29:49 +01:00
父节点 9c8040dbca
当前提交 82a5edc9b7
共有 2 个文件被更改,包括 39 次插入1 次删除

查看文件

@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 207;
$config['migration_version'] = 208;
/*
|--------------------------------------------------------------------------

查看文件

@ -0,0 +1,38 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_add_indexes_lotw_users extends CI_Migration
{
public function up()
{
if ($this->db->table_exists('lotw_users')) {
// add an index on callsign if no index exists on that column
$callsignIndex = $this->db->query("SHOW INDEX FROM lotw_users WHERE Column_name = 'callsign'");
if ($callsignIndex->num_rows() == 0) {
$this->db->query("ALTER TABLE lotw_users ADD INDEX `callsign` (`callsign`)");
}
// add an index on lastupload if it doesn't exist
$lastuploadIndex = $this->db->query("SHOW INDEX FROM lotw_users WHERE Column_name = 'lastupload'");
if ($lastuploadIndex->num_rows() == 0) {
$this->db->query("ALTER TABLE lotw_users ADD INDEX `lastupload` (`lastupload`)");
}
}
}
public function down()
{
if ($this->db->table_exists('lotw_users')) {
// drop the indexes we might have created (only if the index name matches)
$li = $this->db->query("SHOW INDEX FROM lotw_users WHERE Key_name = 'lastupload'");
if ($li->num_rows() > 0) {
$this->db->query("ALTER TABLE lotw_users DROP INDEX `lastupload`");
}
$ci = $this->db->query("SHOW INDEX FROM lotw_users WHERE Key_name = 'callsign'");
if ($ci->num_rows() > 0) {
$this->db->query("ALTER TABLE lotw_users DROP INDEX `callsign`");
}
}
}
}