Skip to content

feat(api): allow choosing MySQL or PostgreSQL via DB_ENGINE#151

Merged
vvatelot merged 6 commits into
mainfrom
feat/api-mysql-postgres-db-engine
Jul 15, 2026
Merged

feat(api): allow choosing MySQL or PostgreSQL via DB_ENGINE#151
vvatelot merged 6 commits into
mainfrom
feat/api-mysql-postgres-db-engine

Conversation

@vvatelot

@vvatelot vvatelot commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Add DB_ENGINE (sqlite, mysql, postgres) to build DATABASE_URL automatically, with optional explicit override
  • Split Docker Compose into db-mysql and db-postgres profiles and add Task commands for each engine
  • Start MySQL/PostgreSQL dev containers from start_dev_infra.sh based on DB_ENGINE, with aiomysql and asyncpg drivers

Test plan

  • uv run pytest test/components/ecoindex/config/test_settings.py
  • DB_ENGINE=sqlite task api:start-dev — API starts with local SQLite file
  • DB_ENGINE=mysql task api:start-dev — MySQL container starts, migrations apply, API responds on /health
  • DB_ENGINE=postgres task api:start-dev — PostgreSQL container starts, migrations apply, API responds on /health
  • task api:docker-up-mysql -- -d — full stack starts with MySQL profile
  • task api:docker-up-postgres -- -d — full stack starts with PostgreSQL profile

Made with Cursor

Developers can now pick sqlite, mysql, or postgres at startup through a single DB_ENGINE setting, with Docker Compose profiles and local dev containers aligned on the same configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling components labels Jul 15, 2026
vvatelot and others added 2 commits July 15, 2026 12:01
* fix(api): support emoji and punycode domains in analysis tasks

WebPage validation stores URLs as Unicode, which breaks requests for emoji
domains like xn--3s8h30f.ws. Use AnyHttpUrl for punycode conversion and pass
the encoded URL to the worker queue.

Fixes cnumr/EcoIndex#416

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): include request error details when URL pre-check fails

Expose SSL, timeout, and DNS errors in the unreachable URL response instead of empty parentheses.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Use an empty default and resolve it in the model validator so type checkers accept Settings().DATABASE_URL where a str is required.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the API label Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Coverage PR 151

Branch coverage •
FileStmtsMissCoverMissing
components/ecoindex/config
   settings.py610100% 
TOTAL167056366% 

vvatelot and others added 3 commits July 15, 2026 15:07
Alembic needs projects/ecoindex_api as the working directory so it can find alembic.ini and load the local .env during init-dev-project.

Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure mysql/postgres containers are up before migration-upgrade and document which DB_HOST to use for local dev versus Docker Compose.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vvatelot vvatelot self-assigned this Jul 15, 2026
@vvatelot
vvatelot merged commit ba6ac89 into main Jul 15, 2026
21 checks passed
@vvatelot
vvatelot deleted the feat/api-mysql-postgres-db-engine branch July 15, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API components documentation Improvements or additions to documentation tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant