diff --git a/app/Model/AppModel.php b/app/Model/AppModel.php index 866dcae44..b4997937e 100644 --- a/app/Model/AppModel.php +++ b/app/Model/AppModel.php @@ -1494,9 +1494,22 @@ class AppModel extends Model $indexArray[] = array('shadow_attributes', 'last_seen'); break; case 'createUUIDsConstraints': + $this->__dropIndex('events', 'uuid'); $sqlArray[] = "ALTER TABLE events ADD CONSTRAINT `uuid` UNIQUE (uuid);"; + $this->__dropIndex('attributes', 'uuid'); $sqlArray[] = "ALTER TABLE attributes ADD CONSTRAINT `uuid` UNIQUE (uuid);"; + $this->__dropIndex('objects', 'uuid'); $sqlArray[] = "ALTER TABLE objects ADD CONSTRAINT `uuid` UNIQUE (uuid);"; + $this->__dropIndex('sightings', 'uuid'); + $sqlArray[] = "ALTER TABLE sightings ADD CONSTRAINT `uuid` UNIQUE (uuid);"; + $this->__dropIndex('dashboards', 'uuid'); + $sqlArray[] = "ALTER TABLE dashboards ADD CONSTRAINT `uuid` UNIQUE (uuid);"; + $this->__dropIndex('inbox', 'uuid'); + $sqlArray[] = "ALTER TABLE inbox ADD CONSTRAINT `uuid` UNIQUE (uuid);"; + $this->__dropIndex('organisations', 'uuid'); + $sqlArray[] = "ALTER TABLE organisations ADD CONSTRAINT `uuid` UNIQUE (uuid);"; + $this->__dropIndex('tag_collections', 'uuid'); + $sqlArray[] = "ALTER TABLE tag_collections ADD CONSTRAINT `uuid` UNIQUE (uuid);"; break; default: return false; @@ -2303,7 +2316,6 @@ class AppModel extends Model } } } - $this->updateDatabase('makeAttributeUUIDsUnique'); return $counter; } @@ -2342,7 +2354,6 @@ class AppModel extends Model } } } - $this->updateDatabase('makeEventUUIDsUnique'); return $counter; } @@ -2369,7 +2380,6 @@ class AppModel extends Model } } } - $this->updateDatabase('makeObjectUUIDsUnique'); return $counter; } @@ -2398,7 +2408,6 @@ class AppModel extends Model } } } - $this->updateDatabase('makeClusterUUIDsUnique'); return $counter; } @@ -2413,19 +2422,18 @@ class AppModel extends Model )); $counter = 0; foreach ($duplicates as $duplicate) { - $attributes = $this->Sighting->find('all', array( + $sightings = $this->Sighting->find('all', array( 'recursive' => -1, 'conditions' => array('uuid' => $duplicate['Sighting']['uuid']), )); foreach ($sightings as $k => $sighting) { if ($k > 0) { $this->Sighting->delete($sighting['Sighting']['id']); - $this->Log->createLogEntry('SYSTEM', 'delete', 'Sighting', $sighting['Sighting']['id'], __('Removed sighting (%s)', $sighting['Sighting']['id']), __('Sighting\'s UUID duplicated (%s)', $sighting['Sighting']['uuid'])); + // $this->Log->createLogEntry('SYSTEM', 'delete', 'Sighting', $sighting['Sighting']['id'], __('Removed sighting (%s)', $sighting['Sighting']['id']), __('Sighting\'s UUID duplicated (%s)', $sighting['Sighting']['uuid'])); $counter++; } } } - $this->updateDatabase('makeSightingUUIDsUnique'); return $counter; } diff --git a/db_schema.json b/db_schema.json index 320578c07..3c7a76199 100644 --- a/db_schema.json +++ b/db_schema.json @@ -6817,7 +6817,7 @@ "dashboards": { "id": true, "name": false, - "uuid": false, + "uuid": true, "user_id": false, "restrict_to_org_id": false, "restrict_to_permission_flag": false @@ -6920,7 +6920,7 @@ "id": true, "title": false, "type": false, - "uuid": false, + "uuid": true, "user_agent_sha256": false, "ip": false, "timestamp": false @@ -6990,7 +6990,7 @@ }, "organisations": { "id": true, - "uuid": false, + "uuid": true, "name": false }, "org_blocklists": { @@ -7077,7 +7077,7 @@ "attribute_id": false, "event_id": false, "org_id": false, - "uuid": false, + "uuid": true, "source": false, "type": false }, @@ -7090,7 +7090,7 @@ }, "tag_collections": { "id": true, - "uuid": false, + "uuid": true, "user_id": false, "org_id": false },