### Administration - Update

This is where you can update your portal's current version to a newer version (or equal) or to the development version (master)!...
This update is performed in two steps: first files, then database.

#### File Update

The interface, mainly explanatory, actually only allows the choice of one parameter: the version that will replace the one currently in service on the portal.
The first screen presents:

- version summary: version in service on the portal and latest stable version available
- a variable status message
- a dropdown list allowing an oriented choice of version to prepare the update
- the `Prepare Update` button that allows you to access the second screen after your choice

The second screen indicates preliminary recommendations and reminders of chosen or imposed options for the update. It contains two buttons:

- `Back` ==> (return to first screen) ...
- `Launch Update` ==> triggers a javascript confirmation alert (or not) and launches the update procedure in the deployer ...

You are now in the progressive control and information interface of processes that last between 2 and 3 minutes total.
In case of success, a `Access Administration` button allows you to return to administration on the file update success confirmation screen.

#### Database Migration

If everything went well, you now have access to the `Migrate Database` button which triggers a javascript confirmation alert (or not) and launches the database migration.
Advice: Before launching an update, perform a complete backup of your database via phpMyAdmin or NPDS `/admin.php?op=SavemySQL`.
The following screen summarizes the context, structural differences analysis and generated queries that will be executed via the `Execute Migration` button and modify the database in service...

A final screen will display the result of the database migration and the update as a whole.

In case of database migration failure, a link will allow you to restart the procedure without losing update parameters.

#### Technical Memo

- Every update automatically generates a backup of sensitive files (a .zip archive: file_backup_ followed by timestamp) available in `/lib/deployer/npds_backups/`
- Database migration is an update of the structure and an update of data in the functions and metalang tables. It is based on a comparison of two files containing the SQL schema: the file currently in use and the file from the new version.
  - for structural update, UPDATE queries will be generated based on the comparison.
  - for data update of the functions and metalang tables, `DELETE/INSERT` queries will be generated. This operation preserves your customizations while updating the system code. (this update of these two tables is systematic)
- The entire portal update procedure is monitored and recorded in PHP logs and NPDS logs (`/slogs/install.log`)

NPDS - Administration Manual