diff --git a/backend/scripts/delete_old_data.py b/backend/scripts/delete_old_data.py index a7581068..5ec15121 100755 --- a/backend/scripts/delete_old_data.py +++ b/backend/scripts/delete_old_data.py @@ -40,7 +40,7 @@ async def delete_old_rows(cutoff_date: datetime): async def main(): # Replace 'your_date_field' with the actual name of your date field - cutoff_date = datetime(2022, 12, 31) + cutoff_date = datetime(2023, 12, 31) count = await count_old_rows(cutoff_date) if count == 0: diff --git a/backend/src/data/mongo/main.py b/backend/src/data/mongo/main.py index 5aa1aae8..c8964063 100644 --- a/backend/src/data/mongo/main.py +++ b/backend/src/data/mongo/main.py @@ -5,7 +5,7 @@ def get_conn_str(password: str, database: str) -> str: - return f"mongodb+srv://root:{password}@backend.aqlpb.mongodb.net/{database}?retryWrites=true&w=majority" + return f"mongodb+srv://root:{password}@backend2.e50j8dp.mongodb.net/{database}?retryWrites=true&w=majority" if LOCAL: diff --git a/backend/transfer_mongodb.bash b/backend/transfer_mongodb.bash new file mode 100755 index 00000000..4a1d0e8d --- /dev/null +++ b/backend/transfer_mongodb.bash @@ -0,0 +1,31 @@ +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Export +mongoexport --uri "mongodb+srv://backend.aqlpb.mongodb.net/" --db dev_backend --collection secrets --username root --password "$1" > ./dev_secrets.json +mongoexport --uri "mongodb+srv://backend.aqlpb.mongodb.net/" --db dev_backend --collection users --username root --password "$1" > ./dev_users.json +mongoexport --uri "mongodb+srv://backend.aqlpb.mongodb.net/" --db dev_backend --collection user_months --username root --password "$1" > ./dev_user_months.json + +mongoexport --uri "mongodb+srv://backend.aqlpb.mongodb.net/" --db prod_backend --collection secrets --username root --password "$1" > ./prod_secrets.json +mongoexport --uri "mongodb+srv://backend.aqlpb.mongodb.net/" --db prod_backend --collection users --username root --password "$1" > ./prod_users.json +mongoexport --uri "mongodb+srv://backend.aqlpb.mongodb.net/" --db prod_backend --collection user_months --username root --password "$1" > ./prod_user_months.json + +# Import +mongoimport --uri "mongodb+srv://backend2.e50j8dp.mongodb.net/" --db dev_backend --collection secrets --username root --password "$1" < ./dev_secrets.json +mongoimport --uri "mongodb+srv://backend2.e50j8dp.mongodb.net/" --db dev_backend --collection users --username root --password "$1" < ./dev_users.json +mongoimport --uri "mongodb+srv://backend2.e50j8dp.mongodb.net/" --db dev_backend --collection user_months --username root --password "$1" < ./dev_user_months.json + +mongoimport --uri "mongodb+srv://backend2.e50j8dp.mongodb.net/" --db prod_backend --collection secrets --username root --password "$1" < ./prod_secrets.json +mongoimport --uri "mongodb+srv://backend2.e50j8dp.mongodb.net/" --db prod_backend --collection users --username root --password "$1" < ./prod_users.json +mongoimport --uri "mongodb+srv://backend2.e50j8dp.mongodb.net/" --db prod_backend --collection user_months --username root --password "$1" < ./prod_user_months.json + +# Remove +rm ./dev_secrets.json +rm ./dev_users.json +rm ./dev_user_months.json + +rm ./prod_secrets.json +rm ./prod_users.json +rm ./prod_user_months.json \ No newline at end of file