It's possible for XNAT's database views to become corrupted, especially when developing a new data type or working with complex data. This can lead to odd and unpredictable effects in XNAT. If you're seeing strange behavior but can't identify a cause, dropping the XNAT database views is a possible remedy. On start-up, XNAT checks to see if the views it expects to find are available and inspects them for integrity. If they are missing or corrupted, XNAT will simply drop the views and rebuild them. However, XNAT can't detect corruption of the views sometimes. To force the rebuild of the views, you can use this procedure.
To rebuild the XNAT database views:
- If Tomcat is currently running, stop it.
- Once Tomcat has stopped, run the SQL below (it is also attached to this page as an SQL script file):
- Start the PostgreSQL command-line client psql and paste the commands in directly
Save the commands into a file or download the SQL script file and run them from the command line:
- Run the commands from pgAdmin or another database-management tool
- When the script has completed, restart Tomcat.
The SQL is shown below. Note that you'll want to change the name specified in the call to drop_user_views() to reflect the database user configured for your XNAT deployment.