Open
Conversation
Migrate from TinyDB (JSON file-based) to PostgreSQL with psycopg3 (async) and yoyo-migrations. This eliminates the global threading lock that serialized all DB access and the full JSON rewrite on every mutation. Key changes: - Add async connection pool (psycopg_pool) with db_conn() context manager - Add yoyo-migrations with initial schema for all 8 tables - Create per-entity database modules (installed_apps, identities, terminals, peers, backups, tours, app_usage, kv_store) following conn-first-arg pattern - Convert all service/web layers from sync TinyDB to async Postgres - Convert blinker signals to async (send_async) for DB-writing handlers - Add one-time TinyDB→Postgres data migration on first startup - Remove TEST_ENV distinction — all tests use pytest-docker Postgres - Add docker-compose postgres service for both dev and test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove **/*.sql from .gitignore so migration files are tracked in git; without this, yoyo ran against an empty migrations/ directory, applied no schema, and tests failed with 'relation does not exist' before the fixture yield, leaking the open connection pool - Wrap pool init/teardown in try/finally in app_client and db fixtures so shutdown_database() is always called even when setup fails; the leaked pool's background reconnect task previously blocked event loop shutdown, causing the full 6-hour GitHub Actions timeout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RETURNING *,class_row/dict_row, andLiteralStringSQLsend_async()) for handlers that write to the databaseTEST_ENV/requires_test_envdistinction — all tests use pytest-docker PostgresDatabase modules created
connection.py,migration.py,errors.py,installed_apps.py,identities.py,terminals.py,peers.py,backups.py,tours.py,app_usage.py,kv_store.py,tinydb_migration.pyTest plan
just cleanup)🤖 Generated with Claude Code