Loading sources/database_helper.php +2 −2 Original line number Diff line number Diff line Loading @@ -721,8 +721,8 @@ function _helper_add_table_field_sql($this_ref, $table_name, $name, $_type, $def } $final_type = str_replace(array('*', '?'), array('', ''), $_final_type); $extra = ''; if ((($final_type != 'LONG_TEXT') || (strpos(get_db_type(), 'mysql') === false)) && (($_final_type[0] != '?') || ($default !== null))) { $extra = is_null($default) ? 'DEFAULT NULL' : ('DEFAULT ' . (is_string($default) ? ('\'' . db_escape_string($default) . '\'') : strval($default))); if ((($final_type != 'LONG_TEXT') || (strpos(get_db_type(), 'mysql') === false)) && ($default !== null)) { $extra = 'DEFAULT ' . (is_string($default) ? ('\'' . db_escape_string($default) . '\'') : strval($default)); } $query = 'ALTER TABLE ' . $this_ref->table_prefix . $table_name; $query .= ' ADD ' . $name . ' ' . str_replace(' auto_increment', ' PRIMARY KEY auto_increment', $type_remap[$final_type]) . ' ' . $extra . ' ' . $tag; Loading sources/database_repair.php +5 −5 Original line number Diff line number Diff line Loading @@ -459,15 +459,12 @@ class DatabaseRepair sort($expected_key_fields); sort($existent_key_fields); if ($expected_key_fields != $existent_key_fields) { list($drop_key_query, $create_key_query) = $this->fix_table_inconsistent_in_db__bad_primary_key($table_name, $expected_key_fields, isset($meta_tables[$table_name][$field_name]), true); list($drop_key_query) = $this->fix_table_inconsistent_in_db__bad_primary_key($table_name, $expected_key_fields, isset($meta_tables[$table_name][$field_name]), true); $this->sql_fixup = array_merge( array_slice($this->sql_fixup, 0, count($this->sql_fixup) - $fields_added), array($drop_key_query . ';'), array_slice($this->sql_fixup, count($this->sql_fixup) - $fields_added) ); if ((count($expected_key_fields) != 0) || ($existent_tables[$table_name][$expected_key_fields[0]] != '*AUTO')) { $this->sql_fixup[] = $create_key_query . ';'; } $needs_changes = true; } Loading Loading @@ -813,7 +810,10 @@ class DatabaseRepair } $_key_fields = implode(', ', $key_fields); $create_key_query = 'ALTER TABLE ' . get_table_prefix() . $table_name . ' DROP PRIMARY KEY, ADD PRIMARY KEY (' . $_key_fields . ')'; $create_key_query = 'ALTER TABLE ' . get_table_prefix() . $table_name . ' DROP PRIMARY KEY'; if ($_key_fields != '') { $create_key_query .= ', ADD PRIMARY KEY (' . $_key_fields . ')'; } if (!$return_queries) { $this->add_fixup_query($create_key_query); } Loading Loading
sources/database_helper.php +2 −2 Original line number Diff line number Diff line Loading @@ -721,8 +721,8 @@ function _helper_add_table_field_sql($this_ref, $table_name, $name, $_type, $def } $final_type = str_replace(array('*', '?'), array('', ''), $_final_type); $extra = ''; if ((($final_type != 'LONG_TEXT') || (strpos(get_db_type(), 'mysql') === false)) && (($_final_type[0] != '?') || ($default !== null))) { $extra = is_null($default) ? 'DEFAULT NULL' : ('DEFAULT ' . (is_string($default) ? ('\'' . db_escape_string($default) . '\'') : strval($default))); if ((($final_type != 'LONG_TEXT') || (strpos(get_db_type(), 'mysql') === false)) && ($default !== null)) { $extra = 'DEFAULT ' . (is_string($default) ? ('\'' . db_escape_string($default) . '\'') : strval($default)); } $query = 'ALTER TABLE ' . $this_ref->table_prefix . $table_name; $query .= ' ADD ' . $name . ' ' . str_replace(' auto_increment', ' PRIMARY KEY auto_increment', $type_remap[$final_type]) . ' ' . $extra . ' ' . $tag; Loading
sources/database_repair.php +5 −5 Original line number Diff line number Diff line Loading @@ -459,15 +459,12 @@ class DatabaseRepair sort($expected_key_fields); sort($existent_key_fields); if ($expected_key_fields != $existent_key_fields) { list($drop_key_query, $create_key_query) = $this->fix_table_inconsistent_in_db__bad_primary_key($table_name, $expected_key_fields, isset($meta_tables[$table_name][$field_name]), true); list($drop_key_query) = $this->fix_table_inconsistent_in_db__bad_primary_key($table_name, $expected_key_fields, isset($meta_tables[$table_name][$field_name]), true); $this->sql_fixup = array_merge( array_slice($this->sql_fixup, 0, count($this->sql_fixup) - $fields_added), array($drop_key_query . ';'), array_slice($this->sql_fixup, count($this->sql_fixup) - $fields_added) ); if ((count($expected_key_fields) != 0) || ($existent_tables[$table_name][$expected_key_fields[0]] != '*AUTO')) { $this->sql_fixup[] = $create_key_query . ';'; } $needs_changes = true; } Loading Loading @@ -813,7 +810,10 @@ class DatabaseRepair } $_key_fields = implode(', ', $key_fields); $create_key_query = 'ALTER TABLE ' . get_table_prefix() . $table_name . ' DROP PRIMARY KEY, ADD PRIMARY KEY (' . $_key_fields . ')'; $create_key_query = 'ALTER TABLE ' . get_table_prefix() . $table_name . ' DROP PRIMARY KEY'; if ($_key_fields != '') { $create_key_query .= ', ADD PRIMARY KEY (' . $_key_fields . ')'; } if (!$return_queries) { $this->add_fixup_query($create_key_query); } Loading