Skip to content

Commit

Permalink
Merge pull request #278 from Normal-OJ/fix/migrate-drop-contests
Browse files Browse the repository at this point in the history
fix(migrations): add: 2023_11_06_000001_drop_contests.py
  • Loading branch information
aokblast authored Nov 6, 2023
2 parents 3a9a353 + db6a38f commit b82175a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions migrations/2023_11_06_000001_drop_contests.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

MONGO_HOST = os.getenv('MONGO_HOST', 'mongomock://localhost')
DATABASE = 'normal-oj'
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b82175a

Please sign in to comment.