<?php
// изменение type_value поля связи
$sqlQuery = "SELECT * FROM " . $config["table_prefix"] . "fields WHERE type_field=5";
$result = run_query($sqlQuery);
while ($row = mysqli_fetch_assoc($result)) {
    $sqlQuery2 = "SELECT table_id FROM " . $config["table_prefix"] . "fields WHERE id=" . $row['type_value'];
    $result2 = run_query($sqlQuery2);
    $row2 = mysqli_fetch_array($result2);

    $sqlQuery3 = "SELECT id FROM " . $config["table_prefix"] . "filters WHERE table_id=" . $row2['table_id'];
    $result3 = run_query($sqlQuery3);
    $row3 = mysqli_fetch_array($result3);

    $sqlQuery3 = "UPDATE " . $config["table_prefix"] . "fields SET type_value='" . $row2['table_id'] . "|" . $row['type_value'] . "|" . $row3['id'] . "' WHERE id=" . $row['id'];
    run_query($sqlQuery3);
}

// изменение таблицы users
run_query("ALTER TABLE " . $config["table_prefix"] . "users CHANGE `fio` `fio` VARCHAR(255)");
run_query("ALTER TABLE " . $config["table_prefix"] . "users CHANGE `e_mail` `e_mail` VARCHAR(255)");
run_query("ALTER TABLE " . $config["table_prefix"] . "users CHANGE `login` `login` VARCHAR(255)");
run_query("ALTER TABLE " . $config["table_prefix"] . "users CHANGE `password` `password` VARCHAR(255)");
run_query("ALTER TABLE " . $config["table_prefix"] . "users ADD `code` VARCHAR(255) AFTER `password`");
run_query("UPDATE " . $config["table_prefix"] . "users SET `code` = ''");

// обновляем номер версии
run_query("UPDATE " . $config["table_prefix"] . "config SET `version` = '010501'");
?>