## Plan **File to modify:** `devplacepy/database/schema.py` **Function:** `migrate_ai_gateway_settings()` (lines 1191–1212) **Action:** Insert one `if` block after the `gateway_vision_key` migration (after line 1205 in the current file). **Exact code to add:** ```python if not get_setting("gateway_embed_key", "") and openrouter: set_setting("gateway_embed_key", openrouter) logger.info("Migrated gateway embed key from environment") ``` **Rationale:** `gateway_api_key` and `gateway_vision_key` are already migrated from the environment on first boot. This adds the same treatment for `gateway_embed_key`. The runtime fallback chain in `effective_config()` remains untouched and will continue to work as before for any case where the key is still empty. --- ## Definition of Done - [ ] The change is applied to `devplacepy/database/schema.py` – the new `if` block is present immediately after the `gateway_vision_key` migration. - [ ] Project test command succeeds: ``` pip install -e '.[dev]' -q --break-system-packages && make test-unit ``` (The `--break-system-packages` flag is a workaround for the current environment’s PEP 668 restriction. In a normal environment with a virtual environment, omit that flag.) - [ ] Project lint command succeeds: ``` pip install -q ruff --break-system-packages && ruff check . ``` - [ ] Manual verification (optional but recommended): Set `OPENROUTER_API_KEY=sk-test` in the environment, import and run `migrate_ai_gateway_settings()`, then confirm `get_setting("gateway_embed_key")` returns `"sk-test"`.