Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #102 from ScilifelabDataCentre/develop
Browse files Browse the repository at this point in the history
Missing db migration
  • Loading branch information
talavis authored Jun 22, 2021
2 parents d3ed572 + e9aefbf commit 6abeec4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/db_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import utils
from migrations import MIGRATIONS

DB_VERSION = 2
DB_VERSION = 3


def check_db(config: dict):
Expand Down
12 changes: 11 additions & 1 deletion backend/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,15 @@ def migrate_v1_to_v2(db):
db["datasets"].update_many({}, {"$unset": {"cross_references": ""}})


def migrate_v2_to_v3(db):
"""
Update the database fields to match the changes in the data structure.
* Remove the ``DATA_LIST`` and ``STATISTICS`` permissions from all users.
"""
logging.info("Remove the DATA_LIST and STATISTICS permissions")
db["users"].update_many({}, {"$pull": {"permissions": {"$in": ["STATISTICS", "DATA_LIST"]}}})


# Position 0 is empty since the first release is 1
MIGRATIONS = [None, migrate_v1_to_v2]
MIGRATIONS = [None, migrate_v1_to_v2, migrate_v2_to_v3]

0 comments on commit 6abeec4

Please sign in to comment.