diff --git a/migrations/2023_11_06_000001_drop_contests.py b/migrations/2023_11_06_000001_drop_contests.py new file mode 100644 index 0000000..f10b239 --- /dev/null +++ b/migrations/2023_11_06_000001_drop_contests.py @@ -0,0 +1,15 @@ +import pymongo + +from . import MONGO_HOST, DATABASE + + +def main(): + client = pymongo.MongoClient(MONGO_HOST) + db = client[DATABASE] + collection = db['course'] + collection.update_many({}, {'$unset': {'contests': 1}}) + collection = db['problem'] + collection.update_many({}, {'$unset': {'contests': 1}}) + + +main() diff --git a/migrations/__init__.py b/migrations/__init__.py new file mode 100644 index 0000000..de74105 --- /dev/null +++ b/migrations/__init__.py @@ -0,0 +1,4 @@ +import os + +MONGO_HOST = os.getenv('MONGO_HOST', 'mongomock://localhost') +DATABASE = 'normal-oj' diff --git a/pyproject.toml b/pyproject.toml index bb2a0aa..96fd1b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ PyJWT = "^2.5" requests = "^2.31" mosspy = "^1.0" redis = "^4.3" +pymongo = "^4.5.0" [tool.poetry.group.dev.dependencies] pytest = "^7.1"