From 9abb2f19df0f9459899781dd3628e7dcc32397ae Mon Sep 17 00:00:00 2001 From: anmol thapar Date: Tue, 8 Oct 2024 10:28:01 +0100 Subject: [PATCH 1/4] Add data migration script to set default species field for all projects --- README.md | 11 +++++++++++ migrations/20241008_default_species.sh | 13 +++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 migrations/20241008_default_species.sh 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..4ef9e10 --- /dev/null +++ b/migrations/20241008_default_species.sh @@ -0,0 +1,13 @@ +#!/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 + redis-cli HSET "$key" species "Streptococcus pneumoniae" +done \ No newline at end of file From e7b77d8e5f3d1f34692eaca4816a7759c4da5523 Mon Sep 17 00:00:00 2001 From: anmol thapar Date: Wed, 9 Oct 2024 09:21:11 +0100 Subject: [PATCH 2/4] Set default species field for all projects if it is empty --- migrations/20241008_default_species.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migrations/20241008_default_species.sh b/migrations/20241008_default_species.sh index 4ef9e10..f3da5bf 100755 --- a/migrations/20241008_default_species.sh +++ b/migrations/20241008_default_species.sh @@ -9,5 +9,8 @@ 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 - redis-cli HSET "$key" species "Streptococcus pneumoniae" + 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 From abc3c238e4e3bc6a3f64e77b0ebfcdb336a5ffc6 Mon Sep 17 00:00:00 2001 From: absternator Date: Wed, 9 Oct 2024 08:27:01 +0000 Subject: [PATCH 3/4] fix: test 1 --- src/beebop_deploy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From 5fb934f3ddf60fb8340c3eebe33c5cc0fb707af7 Mon Sep 17 00:00:00 2001 From: absternator Date: Wed, 9 Oct 2024 09:01:40 +0000 Subject: [PATCH 4/4] chore: remove push tests not on main --- .github/workflows/Pytest.yml | 2 -- 1 file changed, 2 deletions(-) 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