Database Best Practices Connection Management ALWAYS use the context manager: - NEVER call manually. - Deadlock Prevention : When calling write functions (like ) from within an existing transaction, MUST pass the active cursor . Migration System The migration system tracks versions in the table. Adding a New Migration: 1. Create a migration function in . 2. Register it in the list. 3. Update the base schema in . Rules: - Check if columns/indices exist before creating. - Migrations must be idempotent. - Never delete or modify existing migrations. Schema Overview Main table: - Core Fields: , ,…