[Migration] Check if indexes already exist before trying to add them
这个提交包含在:
父节点
2de85a6e3a
当前提交
3ab625062c
共有 1 个文件被更改,包括 15 次插入 和 2 次删除
|
|
@ -5,8 +5,21 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
class Migration_dxcc_index extends CI_Migration {
|
class Migration_dxcc_index extends CI_Migration {
|
||||||
|
|
||||||
public function up() {
|
public function up() {
|
||||||
$this->db->query("ALTER TABLE `dxcc_prefixes` ADD INDEX `idx_dxcc_prefixes_logic` (`call`, `start`, `end`)");
|
|
||||||
$this->db->query("ALTER TABLE `dxcc_exceptions` ADD INDEX `idx_dxcc_exceptions_logic` (`call`, `start`, `end`)");
|
// check if index idx_dxcc_prefixes_logic exists
|
||||||
|
// if not, add it
|
||||||
|
$prefixes_index = $this->db->query("SHOW INDEX FROM dxcc_prefixes WHERE Key_name = 'idx_dxcc_prefixes_logic'")->num_rows();
|
||||||
|
if ($prefixes_index == 0) {
|
||||||
|
$this->db->query("ALTER TABLE `dxcc_prefixes` ADD INDEX `idx_dxcc_prefixes_logic` (`call`, `start`, `end`)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// check if index dxcc_exceptions exists
|
||||||
|
// if not, add it
|
||||||
|
$exceptions_index = $this->db->query("SHOW INDEX FROM dxcc_exceptions WHERE Key_name = 'idx_dxcc_exceptions_logic'")->num_rows();
|
||||||
|
if ($exceptions_index == 0) {
|
||||||
|
$this->db->query("ALTER TABLE `dxcc_exceptions` ADD INDEX `idx_dxcc_exceptions_logic` (`call`, `start`, `end`)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(){
|
public function down(){
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用