diff --git a/application/migrations/001_add_lotw_credentials.php b/application/migrations/001_add_lotw_credentials.php index ab1608c5..a61ab8ab 100644 --- a/application/migrations/001_add_lotw_credentials.php +++ b/application/migrations/001_add_lotw_credentials.php @@ -1,21 +1,21 @@ -dbforge->add_column('users', $fields); + 'user_lotw_name VARCHAR(32) DEFAULT NULL', + 'user_lotw_password VARCHAR(64) DEFAULT NULL' + ); + + $this->dbforge->add_column('users', $fields); } public function down() { $this->dbforge->drop_column('users', 'user_lotw_name'); - $this->dbforge->drop_column('users', 'user_lotw_password'); + $this->dbforge->drop_column('users', 'user_lotw_password'); } } -?> diff --git a/application/migrations/002_add_config_table.php b/application/migrations/002_add_config_table.php index 9173bafb..ae3c541d 100644 --- a/application/migrations/002_add_config_table.php +++ b/application/migrations/002_add_config_table.php @@ -1,11 +1,12 @@ -dbforge->add_field('id'); - + $this->dbforge->add_field('id'); + $this->dbforge->add_field(array( 'lotw_download_url' => array( 'type' => 'VARCHAR', @@ -15,22 +16,22 @@ class Migration_add_config_table extends CI_Migration { 'type' => 'VARCHAR', 'constraint' => 255, ), - 'lotw_rcvd_mark' => array( + 'lotw_rcvd_mark' => array( 'type' => 'VARCHAR', 'constraint' => 1, ), )); - - - $this->dbforge->create_table('config'); - - $data = array( - 'lotw_download_url' => 'https://p1k.arrl.org/lotwuser/lotwreport.adi', - 'lotw_upload_url' => 'https://p1k.arrl.org/lotwuser/upload', - 'lotw_rcvd_mark' => 'Y' - ); - $this->db->insert('config', $data); + + $this->dbforge->create_table('config'); + + $data = array( + 'lotw_download_url' => 'https://p1k.arrl.org/lotwuser/lotwreport.adi', + 'lotw_upload_url' => 'https://p1k.arrl.org/lotwuser/upload', + 'lotw_rcvd_mark' => 'Y' + ); + + $this->db->insert('config', $data); } public function down() @@ -38,4 +39,3 @@ class Migration_add_config_table extends CI_Migration { $this->dbforge->drop_table('config'); } } -?> \ No newline at end of file diff --git a/application/migrations/003_add_lotw_login_url.php b/application/migrations/003_add_lotw_login_url.php index c3ad57f0..e5543bf1 100644 --- a/application/migrations/003_add_lotw_login_url.php +++ b/application/migrations/003_add_lotw_login_url.php @@ -1,13 +1,14 @@ -dbforge->add_column('config', $fields); - + + $this->dbforge->add_column('config', $fields); + $sql = "UPDATE config SET lotw_login_url = 'https://p1k.arrl.org/lotwuser/default' WHERE id=1"; $this->db->query($sql); @@ -15,7 +16,6 @@ class Migration_add_lotw_login_url extends CI_Migration { public function down() { - $this->dbforge->drop_column('config', 'lotw_login_url'); + $this->dbforge->drop_column('config', 'lotw_login_url'); } } -?> diff --git a/application/migrations/205_add_workable_dxcc_indexes.php b/application/migrations/205_add_workable_dxcc_indexes.php index 3c8cd90c..deb256df 100644 --- a/application/migrations/205_add_workable_dxcc_indexes.php +++ b/application/migrations/205_add_workable_dxcc_indexes.php @@ -1,49 +1,50 @@ db->db_debug = false; - + // Check if index already exists - $index_exists = $this->db->query("SHOW INDEX FROM ".$this->config->item('table_name')." WHERE Key_name = 'idx_workable_dxcc'")->num_rows(); - + $index_exists = $this->db->query("SHOW INDEX FROM " . $this->config->item('table_name') . " WHERE Key_name = 'idx_workable_dxcc'")->num_rows(); + if ($index_exists == 0) { - $sql = "ALTER TABLE ".$this->config->item('table_name')." ADD INDEX `idx_workable_dxcc` (`COL_COUNTRY`, `station_id`, `COL_PROP_MODE`)"; + $sql = "ALTER TABLE " . $this->config->item('table_name') . " ADD INDEX `idx_workable_dxcc` (`COL_COUNTRY`, `station_id`, `COL_PROP_MODE`)"; $this->db->query($sql); } - + // Add index for confirmation status columns - $conf_index_exists = $this->db->query("SHOW INDEX FROM ".$this->config->item('table_name')." WHERE Key_name = 'idx_qsl_confirmations'")->num_rows(); - + $conf_index_exists = $this->db->query("SHOW INDEX FROM " . $this->config->item('table_name') . " WHERE Key_name = 'idx_qsl_confirmations'")->num_rows(); + if ($conf_index_exists == 0) { - $sql = "ALTER TABLE ".$this->config->item('table_name')." ADD INDEX `idx_qsl_confirmations` (`COL_QSL_RCVD`, `COL_LOTW_QSL_RCVD`, `COL_EQSL_QSL_RCVD`, `COL_QRZCOM_QSO_DOWNLOAD_STATUS`)"; + $sql = "ALTER TABLE " . $this->config->item('table_name') . " ADD INDEX `idx_qsl_confirmations` (`COL_QSL_RCVD`, `COL_LOTW_QSL_RCVD`, `COL_EQSL_QSL_RCVD`, `COL_QRZCOM_QSO_DOWNLOAD_STATUS`)"; $this->db->query($sql); } - + $this->db->db_debug = true; } public function down() { $this->db->db_debug = false; - + // Drop the indexes if they exist - $index_exists = $this->db->query("SHOW INDEX FROM ".$this->config->item('table_name')." WHERE Key_name = 'idx_workable_dxcc'")->num_rows(); + $index_exists = $this->db->query("SHOW INDEX FROM " . $this->config->item('table_name') . " WHERE Key_name = 'idx_workable_dxcc'")->num_rows(); if ($index_exists > 0) { - $this->db->query("ALTER TABLE ".$this->config->item('table_name')." DROP INDEX `idx_workable_dxcc`"); + $this->db->query("ALTER TABLE " . $this->config->item('table_name') . " DROP INDEX `idx_workable_dxcc`"); } - - $conf_index_exists = $this->db->query("SHOW INDEX FROM ".$this->config->item('table_name')." WHERE Key_name = 'idx_qsl_confirmations'")->num_rows(); + + $conf_index_exists = $this->db->query("SHOW INDEX FROM " . $this->config->item('table_name') . " WHERE Key_name = 'idx_qsl_confirmations'")->num_rows(); if ($conf_index_exists > 0) { - $this->db->query("ALTER TABLE ".$this->config->item('table_name')." DROP INDEX `idx_qsl_confirmations`"); + $this->db->query("ALTER TABLE " . $this->config->item('table_name') . " DROP INDEX `idx_qsl_confirmations`"); } - + $this->db->db_debug = true; } }