diff --git a/application/config/migration.php b/application/config/migration.php index 4e2bbf83c..b8f51a4af 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 262; +$config['migration_version'] = 263; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Stationsetup.php b/application/controllers/Stationsetup.php index 0b793e6b5..f34088f4a 100644 --- a/application/controllers/Stationsetup.php +++ b/application/controllers/Stationsetup.php @@ -599,6 +599,7 @@ class Stationsetup extends CI_Controller { 'hrdlog_username' => xss_clean($loc['hrdlog_username'] ?? null), 'eqslqthnickname' => xss_clean($loc['eqslqthnickname'] ?? null), 'webadifapiurl' => 'https://qo100dx.club/api', + 'station_uuid' => xss_clean($loc['station_uuid'] ?? null), 'user_id' => $this->session->userdata('user_id'), ]; diff --git a/application/migrations/263_add_station_uuid.php b/application/migrations/263_add_station_uuid.php new file mode 100644 index 000000000..eb8479ac3 --- /dev/null +++ b/application/migrations/263_add_station_uuid.php @@ -0,0 +1,24 @@ +dbtry("ALTER TABLE station_profile ADD COLUMN station_uuid varchar(36) DEFAULT NULL AFTER webadifrealtime"); + $this->dbtry("UPDATE station_profile SET station_uuid = UUID() WHERE station_uuid IS NULL"); + } + + public function down() + { + $this->dbtry("ALTER TABLE station_profile DROP COLUMN station_uuid"); + } + + function dbtry($what) { + try { + $this->db->query($what); + } catch (Exception $e) { + log_message("error", "Something gone wrong while altering station_uuid: ".$e." // Executing: ".$this->db->last_query()); + } + } +} diff --git a/application/models/Stations.php b/application/models/Stations.php index bc7bf9f19..b5e894aca 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -160,6 +160,7 @@ class Stations extends CI_Model { 'webadifapikey' => xss_clean($this->input->post('webadifapikey', true)), 'webadifapiurl' => 'https://qo100dx.club/api', 'webadifrealtime' => xss_clean($this->input->post('webadifrealtime', true)), + 'station_uuid' => $this->db->query("SELECT UUID() as uuid")->row()->uuid, ); // Insert Records & return insert id // diff --git a/application/models/Stationsetup_model.php b/application/models/Stationsetup_model.php index 1e87c6f70..8dd581b06 100644 --- a/application/models/Stationsetup_model.php +++ b/application/models/Stationsetup_model.php @@ -234,7 +234,7 @@ class Stationsetup_model extends CI_Model { } function list_all_locations() { - $sql = "select dxcc_entities.end, station_profile.station_id, station_profile_name, station_profile.hrdlog_username, station_gridsquare, station_city, station_iota, station_sota, station_callsign, station_power, station_dxcc, dxcc_entities.name as dxccname, dxcc_entities.prefix as dxccprefix, station_cnty, station_cq, station_itu, station_active, eqslqthnickname, state, county, station_sig, station_sig_info, qrzrealtime, station_wwff, station_pota, oqrs, oqrs_text, oqrs_email, webadifrealtime, clublogrealtime, clublogignore, hrdlogrealtime, creation_date, last_modified + $sql = "select dxcc_entities.end, station_profile.station_id, station_profile_name, station_profile.hrdlog_username, station_gridsquare, station_city, station_iota, station_sota, station_callsign, station_power, station_dxcc, dxcc_entities.name as dxccname, dxcc_entities.prefix as dxccprefix, station_cnty, station_cq, station_itu, station_active, eqslqthnickname, state, county, station_sig, station_sig_info, qrzrealtime, station_wwff, station_pota, oqrs, oqrs_text, oqrs_email, webadifrealtime, clublogrealtime, clublogignore, hrdlogrealtime, creation_date, last_modified, station_uuid from station_profile join dxcc_entities on station_profile.station_dxcc = dxcc_entities.adif where user_id = ?"; @@ -304,6 +304,11 @@ class Stationsetup_model extends CI_Model { return 0; } else { // Insert new location + // Generate UUID if not provided + if (empty($dbdata['station_uuid'])) { + $dbdata['station_uuid'] = $this->db->query("SELECT UUID() as uuid")->row()->uuid; + } + $this->db->insert('station_profile', $dbdata); $location_id = $this->db->insert_id();