diff --git a/README.md b/README.md index 4be6d7f..1f4a0d2 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ TESTING=True ``` 2. Login and submit a record to create all the collections -3. Run `triggers/management/change_streams_pre_and_post.py` +3. Run `api/models/management/change_streams_pre_and_post.py` 4. Create the catalog and typeahead indexes from `atlas/` (TODO detailed instructions) ### Triggers diff --git a/api/models/management/change_streams_pre_and_post.py b/api/models/management/change_streams_pre_and_post.py index aec4505..49daecd 100644 --- a/api/models/management/change_streams_pre_and_post.py +++ b/api/models/management/change_streams_pre_and_post.py @@ -1,10 +1,11 @@ import asyncio -from api.config import get_settings -from api.models.catalog import DatasetMetadataDOC from beanie import init_beanie from motor.motor_asyncio import AsyncIOMotorClient +from api.config import get_settings +from api.models.catalog import DatasetMetadataDOC + async def main(): db = AsyncIOMotorClient(get_settings().db_connection_string) diff --git a/triggers/management/change_streams_pre_and_post.py b/triggers/management/change_streams_pre_and_post.py deleted file mode 100755 index ebfaef1..0000000 --- a/triggers/management/change_streams_pre_and_post.py +++ /dev/null @@ -1,20 +0,0 @@ -import asyncio - -from beanie import init_beanie -from motor.motor_asyncio import AsyncIOMotorClient -from api.config import get_settings -from api.models.catalog import DatasetMetadataDOC - - -async def main(): - db = AsyncIOMotorClient(get_settings().db_connection_string) - await init_beanie(database=db[get_settings().database_name], document_models=[DatasetMetadataDOC]) - # https://www.mongodb.com/docs/manual/reference/command/collMod/#change-streams-with-document-pre--and-post-images - # This enables us to get the record id of a deleted submission within a trigger. We need this for removing - # discovery records when a submission is deleted - await db[get_settings().database_name].command( - ({'collMod': DatasetMetadataDOC.get_collection_name(), "changeStreamPreAndPostImages": {'enabled': True}})) - db.close() - -if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file