mirror of https://github.com/MISP/MISP
fix: Fixed an issue where a normal index was attempted to be created for a text field causing the installation to fail
parent
9d6f380957
commit
8302048dd9
|
@ -233,7 +233,7 @@ CREATE TABLE IF NOT EXISTS galaxy_clusters (
|
|||
source varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
authors text COLLATE utf8_bin NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
INDEX `value` (`value`),
|
||||
INDEX `value` (`value`(255)),
|
||||
INDEX `uuid` (`uuid`),
|
||||
INDEX `tag_name` (`tag_name`),
|
||||
INDEX `type` (`type`)
|
||||
|
|
|
@ -478,7 +478,7 @@ class AppModel extends Model {
|
|||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;";
|
||||
|
||||
$this->__addIndex('galaxy_clusters', 'value');
|
||||
$this->__addIndex('galaxy_clusters', 'value', 255);
|
||||
$this->__addIndex('galaxy_clusters', 'tag_name');
|
||||
$this->__addIndex('galaxy_clusters', 'uuid');
|
||||
$this->__addIndex('galaxy_clusters', 'type');
|
||||
|
@ -610,14 +610,18 @@ class AppModel extends Model {
|
|||
}
|
||||
}
|
||||
|
||||
private function __addIndex($table, $field) {
|
||||
private function __addIndex($table, $field, $length = false) {
|
||||
$dataSourceConfig = ConnectionManager::getDataSource('default')->config;
|
||||
$dataSource = $dataSourceConfig['datasource'];
|
||||
$this->Log = ClassRegistry::init('Log');
|
||||
if ($dataSource == 'Database/Postgres') {
|
||||
$addIndex = "CREATE INDEX idx_" . $table . "_" . $field . " ON " . $table . " (" . $field . ");";
|
||||
} else {
|
||||
$addIndex = "ALTER TABLE `" . $table . "` ADD INDEX `" . $field . "` (`" . $field . "`);";
|
||||
if (isset($length)) {
|
||||
$addIndex = "ALTER TABLE `" . $table . "` ADD INDEX `" . $field . "` (`" . $field . "`);";
|
||||
} else {
|
||||
$addIndex = "ALTER TABLE `" . $table . "` ADD INDEX `" . $field . "` (`" . $field . "`(" . $length . "));";
|
||||
}
|
||||
}
|
||||
$result = true;
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue