You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the project uses SQLite as the database via aiosqlite, which is excellent for local development simplicity (single file, no setup, zero external dependencies). However, SQLite has limitations for production-like scenarios:
❌ Missing advanced features (stored procedures, replication, etc.)
❌ Not representative of real-world deployment environments
The project needs a production-ready database solution with a unified initialization strategy that works identically for both databases.
Depends on: #2 (Implement Alembic for Database Migrations)
Proposed Solution
Add PostgreSQL support alongside SQLite, leveraging the Alembic migration infrastructure introduced in #2. Both databases will use the same versioned migrations on startup. This provides:
Dual database support: PostgreSQL for Docker/production, SQLite for local dev and testing
Ensure that the Alembic env.py introduced in #2 also reads DATABASE_URL from the environment so it targets the correct database.
Phase 4: Verify Migration Compatibility
Confirm that the Alembic migrations introduced in #2 use SQL compatible with both SQLite and PostgreSQL. Address any dialect differences if found (e.g. AUTOINCREMENT vs SERIAL, type mappings).
Phase 5: Documentation Updates
Update README.md:
Add "Database Options" section explaining SQLite vs PostgreSQL use cases
Problem
Currently, the project uses SQLite as the database via
aiosqlite, which is excellent for local development simplicity (single file, no setup, zero external dependencies). However, SQLite has limitations for production-like scenarios:The project needs a production-ready database solution with a unified initialization strategy that works identically for both databases.
Proposed Solution
Add PostgreSQL support alongside SQLite, leveraging the Alembic migration infrastructure introduced in #2. Both databases will use the same versioned migrations on startup. This provides:
Suggested Approach
Phase 1: Docker Infrastructure Setup
Configure Docker Compose to orchestrate PostgreSQL alongside the application service.
Update
compose.yaml:Create
.env.example:Phase 2: Dependencies
Add to
pyproject.toml:Note: Alembic is added as part of #2.
Phase 3: Database Provider Abstraction
Update database configuration (e.g.
databases/database.py):Ensure that the Alembic
env.pyintroduced in #2 also readsDATABASE_URLfrom the environment so it targets the correct database.Phase 4: Verify Migration Compatibility
Confirm that the Alembic migrations introduced in #2 use SQL compatible with both SQLite and PostgreSQL. Address any dialect differences if found (e.g.
AUTOINCREMENTvsSERIAL, type mappings).Phase 5: Documentation Updates
Update
README.md:POSTGRES_PASSWORD,DB_PROVIDER,DATABASE_URL)docker compose upuv run fastapi dev(SQLite via Alembic from Implement Alembic for database migrations #2)Acceptance Criteria
Docker Compose
postgresservice defined with health checkpostgres-data).env.examplecommitted withPOSTGRES_PASSWORDplaceholder.envis git-ignoredApplication Code
asyncpgadded topyproject.tomlDB_PROVIDER/DATABASE_URLenvironment variablesDB_PROVIDER=postgresqlenv.pyreadsDATABASE_URLfrom the environmentTesting
Documentation
.env.exampleexplains required variablesReferences