diff --git a/.github/workflows/Pytest.yml b/.github/workflows/Pytest.yml index b36cd69..1a2d9f1 100644 --- a/.github/workflows/Pytest.yml +++ b/.github/workflows/Pytest.yml @@ -2,8 +2,6 @@ on: push: branches: - main - - master - - "bacpop-*" pull_request: branches: - main diff --git a/README.md b/README.md index 4aa0e94..6074688 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,14 @@ We have one copy of `beebop` deployed: * server: `beebop.dide.ic.ac.uk` * config: `prod.yml` * command to run: `./beebop start prod` + +### Running data migrations + +All data migrations are stored in the migration folder in the server. The naming convention is `YYYYMMDDHHMMSS_.sh`. + +To run them, you can use the following command from the **root**, and replace the migration file with the one you want to run: + +```bash +docker exec beebop-redis bash -c "$(cat ./migrations/)" + +``` diff --git a/migrations/20241008_default_species.sh b/migrations/20241008_default_species.sh new file mode 100755 index 0000000..f3da5bf --- /dev/null +++ b/migrations/20241008_default_species.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -eu + +# This script will set the species field to "Streptococcus pneumoniae" for all projects in the database + +projectKeys=$(redis-cli --scan | grep -E ^beebop:project:[a-zA-Z0-9]+$) + + +echo "Number of found projects: $(echo "$projectKeys" | wc -w)" + +for key in $projectKeys; do + currentSpecies=$(redis-cli HGET "$key" species) + if [ -z "$currentSpecies" ]; then + redis-cli HSET "$key" species "Streptococcus pneumoniae" + fi +done \ No newline at end of file diff --git a/src/beebop_deploy.py b/src/beebop_deploy.py index 1667d48..1f5738c 100644 --- a/src/beebop_deploy.py +++ b/src/beebop_deploy.py @@ -173,7 +173,7 @@ def api_configure(container, cfg): print("[api] Storage db already exists, doing nothing") else: print("[api] Downloading storage database") - args = ["./scripts/download_db"] + args = ["./scripts/download_databases"] mounts = [docker.types.Mount("/beebop/storage", cfg.volumes["storage"])] container.client.containers.run(str(cfg.api_ref), args, mounts=mounts,