Upgrading your NAV database schema
==================================
Sometimes the NAV database schema will change between releases, and
you will need to perform a database upgrade when upgrading your NAV
release.  This file will tell you how.


Upgrade scripts
---------------
This directory (doc/sql/upgrades) contains PostgreSQL scripts to
convert your database schema when a new NAV release has updated it.
Each file will be named after the release version it came with,
meaning that if version 3.0_beta7 has updates to the database schema,
there will be a file called 3.0_beta7.sql here.

Each of these upgrade scripts only upgrade changes that were made
since the previous release.  If several releases have been made since
the version you are already running, you must apply every upgrade
script since then in chronological order.


Performing the schema upgrade
-----------------------------
1. Stop your NAV background processes completely, using "nav stop".
   Then stop your Apache and Tomcat web server processes (as the NAV
   web interface will be busy using the database). Sometimes it is
   necessary to also restart the PostgreSQL server to make sure that
   all database connections from NAV were properly closed.  Of course,
   you should already have done all this before upgrading the NAV
   software.

2. Upgrade your NAV software if you haven't already.

3. Find the appropriate upgrade script(s) from this directory.  Read
   the comments at the top of the file to find more information about
   the upgrade.  After following any instructions in the comments, run
   the upgrade script as the PostgreSQL superuser (usually named
   postgres), or as the NAV database owner: 
     psql -f <upgrade-script.sql> manage <username>

4. If everything looks OK, start NAV again by issuing the command "nav
   start" and then start the Apache and Tomcat web servers.


If something fails during the schema upgrade and you don't know why,
consult the nav-users mailing list.
