This package provides everything needed to create the Diamond flavour of the ISPyB database schema. As we evolve the schema we will publish the update scripts here, so hopefully it should be easy for other users of the schema to stay up-to-date.
- We recommend MariaDB 10.3 or later. You'll need both a MariaDB server and a client.
- Linux with bash is assumed, but it's possible to make this work on other OSes.
- If binary logging is enabled in the DB system, then execute this before importing the test schema:
SET GLOBAL log_bin_trust_function_creators=ON;
- After installing the MariaDB server and client, consider securing the installation by running
mariadb-secure-installation(ormysql_secure_installationon MariaDB 10.3 or older). - Copy
.my.example.cnfto.my.cnfand then edit that file to set theuserandpassword, e.g.user = rootand use thepasswordyou set when securing. Optionally, you can also set e.g.hostandport. - In a test environment run the
build.shfile. This creates the database schema and applies the grants as described in the "Schema" and "Grants" sections below.
Run this on the command-line to create a database and import the schema stored in the SQL files:
mysql -e "CREATE DATABASE ispyb"
mysql ispyb < schemas/ispyb/tables.sql
mysql ispyb < schemas/ispyb/lookups.sql
mysql ispyb < schemas/ispyb/data.sql
mysql ispyb < schemas/ispyb/routines.sqlNote that the data.sql file contains test data, so is only useful in a development environment.
Then apply the grants:
mysql ispyb < grants/ispyb_acquisition.sql
mysql ispyb < grants/ispyb_processing.sql
mysql ispyb < grants/ispyb_web.sqlNote that the grants files are based on roles, so to actually use these grants, you also need to create database users and grant the roles to them. This is described in the header section of the grant files.
Note that SynchWeb currently assumes sql_mode is not set. I.e. it assumes that you have a line like the below in the MariaDB .cnf file:
sql_mode=''
In a development environment it might be useful to log all SQL errors. In MariaDB, you can install the SQL Error Log Plugin to get these logged to a file sql_errors.log inside your datadir. Run this from the mariadb command-line:
INSTALL SONAME 'sql_errlog';
You can verify that it's installed and activated with:
SHOW PLUGINS SONAME WHERE Name = 'SQL_ERROR_LOG';
In order to update a production database, please follow this procedure:
- For all .sql files in
schemas/ispyb/updatesthat have not already been run, read any comments inside the files to decide if/when you should run them. Run a file e.g. like this:
mysql ispyb < schemas/ispyb/updates/2019_03_29_BLSession_archived.sql- If
schemas/ispyb/routines.sqlhas been updated since you installed it, you can simply re-run it. E.g.:
mysql ispyb < schemas/ispyb/routines.sql- If you ran the
routines.sql, then re-apply the grants for the routines. E.g.:
mysql ispyb < grants/ispyb_acquisition.sql
mysql ispyb < grants/ispyb_processing.sql
mysql ispyb < grants/ispyb_web.sql- Please refer to the
Wikifor database diagrams, stored procedure how-to, MariaDB installation and more - A complete
list of tables and columnsfor more details about the tables and columns - A complete
list of stored proceduresfor more details about the stored procedures