Update Database Migration

2026-07-27 00:49:13 -04:00
parent 148a3aecf1
commit 7b8032418a
+21 -1
@@ -1 +1,21 @@
- Migrate from TinyDB to something else
# Migrations from TinyDB to MongoDB Atlas
Steps to include in migration:
1. Migration script should be created to migrate TinyDB json files to mongo
2. The mongo uri string is in environment variable MONGO_URI
3. Refactor from TinyDB should use a minimal set of changes
4. try to reuse function names
5. handle unit test with `mongomock` when possible
6. for integration tests run a local docker container
7. for end to end playwright tests, use a dedicated isolated test db (chore_db_e2e) - the connection string resides in .env.test. wipe test db between tests
8. keep in mind multi-worker gunicorn. do not initialize MongoClient globally at the module root level. Initialize MongoClient lazily within Flask's app factory or use Gunicorns post_fork hook
9. Make sure your migration script or application startup routine explicitly creates unique and secondary indexes on fields that are queried often
10. configure mongo to fail fast when developing:
```
client = MongoClient(
os.getenv("MONGO_URI"),
serverSelectionTimeoutMS=5000, # 5-second timeout instead of 30s
connectTimeoutMS=5000, # 5-second connection handshake limit
maxPoolSize=20 # Prevents hitting Atlas free-tier limits
)
```