{"id":21848959,"url":"https://github.com/ispyb/ispyb-database","last_synced_at":"2025-10-13T06:40:17.510Z","repository":{"id":70096787,"uuid":"513508994","full_name":"ispyb/ispyb-database","owner":"ispyb","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-29T09:17:12.000Z","size":278,"stargazers_count":4,"open_issues_count":8,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-14T14:56:32.177Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ispyb.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-13T12:17:04.000Z","updated_at":"2024-07-29T09:17:16.000Z","dependencies_parsed_at":"2025-04-14T14:46:52.825Z","dependency_job_id":null,"html_url":"https://github.com/ispyb/ispyb-database","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ispyb/ispyb-database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ispyb","download_url":"https://codeload.github.com/ispyb/ispyb-database/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-database/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264537517,"owners_count":23624421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T00:09:44.244Z","updated_at":"2025-10-13T06:40:12.474Z","avatar_url":"https://github.com/ispyb.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ispyb-database\n\nThis package provides everything needed to create the official flavour of the ISPyB database schema. As the schema evolves the update scripts will also be published here, so other users of the schema should be able to stay up-to-date.\n\nBrowsable documentaion with relation diagrams is available on dbdocs:\n[https://dbdocs.io/ispyb/ISPyB](https://dbdocs.io/ispyb/ISPyB)\n\nThis repository is mostly copied from [ispyb-database](https://github.com/DiamondLightSource/ispyb-database). Thanks to [@karl.levik](https://github.com/KarlLevik)\n\n## Requirements\n\n* Server and a client packages of MariaDB 10.3 or later.\n* A Unix-like OS with `bash` shell.\n* The pandoc package (only required to build documentation at the end of the build.sh script.)\n* 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;\n\n## Installation\n\n1. Install MariaDB.\n2. Copy `examples/.my.cnf` to `.my.cnf` and then edit that file to set the `user` and `password`, e.g. `user = root` and use the `password` you set when securing. Optionally, you can also set e.g. `host` and `port`.\n3. In a test environment run the `scripts/build.sh` file. This creates the database schema and applies the grants as described in the \"Schema\" and \"Grants\" sections below.\n\n### Schema\n\nTip: Execute `./build.sh` to create a development `ispyb_build` database and import all the schema and grants files into it.\n\nAlternatively, do it manually:\n\nRun this on the command-line to create a database and import the schema stored in the SQL files:\n\n```bash\nmysql -e \"CREATE DATABASE ispyb\"\nmysql ispyb \u003c schema/1_tables.sql\nmysql ispyb \u003c schema/2_lookups.sql\nmysql ispyb \u003c schema/3_data.sql\nmysql ispyb \u003c schema/4_data_user_portal.sql\nmysql ispyb \u003c schema/5_routines.sql\n```\n\nNote that the `3_data.sql` and `4_data_user_portal.sql` files contains test data, so is only useful in a development environment.\n\n### Grants\n\nThen apply the grants:\n\n```bash\nmysql ispyb \u003c grants/ispyb_acquisition.sql\nmysql ispyb \u003c grants/ispyb_processing.sql\nmysql ispyb \u003c grants/ispyb_web.sql\nmysql ispyb \u003c grants/ispyb_import.sql\n```\nNote 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.\n\n### Miscellaneous Notes\n\nIn a development environment it might be useful to log all SQL errors. In MariaDB, you can install the [SQL Error Log Plugin](https://mariadb.com/kb/en/library/sql-error-log-plugin/) to get these logged to a file `sql_errors.log` inside your datadir. Run this from the mariadb command-line:\n\n```\nINSTALL SONAME 'sql_errlog';\n```\nYou can verify that it's installed and activated with:\n\n```\nSHOW PLUGINS SONAME WHERE Name = 'SQL_ERROR_LOG';\n```\n\n## Updating\n\nIn order to update a production database, please follow this procedure:\n\n1. For all .sql files in `schema/updates` that 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:\n```bash\nmysql ispyb \u003c schema/updates/2019_03_29_BLSession_archived.sql\n```\n2. If `schema/routines.sql` has been updated since you installed it, you can simply re-run it. E.g.:\n```bash\nmysql ispyb \u003c schema/routines.sql\n```\n3. If you ran the `routines.sql`, then re-apply the grants for the routines. E.g.:\n```bash\nmysql ispyb \u003c grants/ispyb_acquisition.sql\nmysql ispyb \u003c grants/ispyb_processing.sql\nmysql ispyb \u003c grants/ispyb_web.sql\nmysql ispyb \u003c grants/ispyb_import.sql\n```\n\n## Useful scripts\n\n* `scripts/build.sh`: Creates a development `ispyb_build` database and imports all the schema and grants files into it.\n* `scripts/missed_updates.sh`: Generates a list of files in the `schema/updates/` folder that haven't been applied.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fispyb%2Fispyb-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fispyb%2Fispyb-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fispyb%2Fispyb-database/lists"}