# Upgrade

## Upgrade NiDB steps

### Install NiDB .rpm

Get the most recent .rpm from github. The latest version may be different than the example below. You can also download the latest release .rpm from <https://github.com/gbook/nidb/releases/latest>

```bash
wget https://github.com/gbook/nidb/releases/download/v2021.10.699/nidb-2021.10.699-1.el8.x86_64.rpm
sudo yum localinstall --nogpgcheck nidb-2021.10.699-1.el8.x86_64.rpm

Last metadata expiration check: 0:28:21 ago on Thu 14 Oct 2021 10:01:28 AM EDT.
Dependencies resolved.
============================================================================================================================================
 Package                    Architecture                 Version                                   Repository                          Size
============================================================================================================================================
Upgrading:
 nidb                       x86_64                       2021.10.699-1.el8                         @commandline                        56 M

Transaction Summary
============================================================================================================================================
Upgrade  1 Package

Total size: 56 M
Is this ok [y/N]:
```

### Complete setup on Website

Visit <http://localhost/setup.php> and follow the pages.

**Entry page** - Turning off access to the website and disabling all modules can help prevent errors during the upgrade. Always remember to backup the database! Click **Next** to continue.

<img src="https://user-images.githubusercontent.com/8302215/137331276-17cd180c-91ec-4220-9c5f-fc55888dfebb.png" alt="" width="563">

<br>

**Pre-requisites** - This page will check for CentOS packages and display an error if a package is missing or the wrong version. If missing any packages, check the output from the NiDB rpm installation or manually install the missing packages. After packages are installed, then refresh this page. Once all pre-requisities are met, click **Next** to continue.

<img src="https://user-images.githubusercontent.com/8302215/137331530-3d1f31f3-8f96-480f-a5d7-42be7f382adc.png" alt="" width="563">

<br>

**SQL database connection** Enter the root SQL password in this screen. If you want to check what tables will be updated, without updating them, select the Debug checkbox. If you encounter issues upgrading large tables, you can choose to limit the size of the tables that are upgraded and you can then update those manually. This is not recommended however. Click **Configure Database** to continue.

<img src="https://user-images.githubusercontent.com/8302215/137331692-45946205-1ace-4789-875b-55851b43f440.png" alt="" width="563">

<br>

**Schema upgrade** The details of the schema upgrade will be displayed. Any errors will be indicated. Click **Next** to continue.

<img src="https://user-images.githubusercontent.com/8302215/137331838-e4ed780e-52b8-4872-b392-fc4eeed71ac4.png" alt="" width="563">

<br>

**Configuration** Any changes (paths, settings, options, etc) can be changed here. Click **Write Config** to continue.

<img src="https://user-images.githubusercontent.com/8302215/137332401-3d0588f7-3225-49bd-b04a-26fb205f99cc.png" alt="" width="563">

<br>

All finished! Click **Done** to complete the upgrade.

<img src="https://user-images.githubusercontent.com/8302215/137332036-d85cc1e9-c669-4777-bb84-47cf0081be12.png" alt="" width="563">

## Upgrade issues

### Schema upgrade errors

The database schema upgrade may not display a SQL error if it occurs, but the errors are stored in the `error_log` table in the database. Find the latest error(s) and the description will help diagnose the issue.

### Row length errors

In phpMyAdmin, select the table in question. Under the **operations** tab, check the table type. If it is `Innodb`, change this to `Aria`, and click **Go**.

### Primary key errors

If the primary key error references a TEXT column (if a TEXT column has a primary key) then delete the key for that column. This can be done in phpMyAdmin.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.neuroinfodb.org/nidb/getting-started/upgrade.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
