Maintenance scripts load .env, so they reach the site's real database

This commit is contained in:
2026-08-24 14:32:38 -04:00
parent ead9fd6b56
commit 4fe4e91ae4
9 changed files with 197 additions and 0 deletions

View File

@@ -75,6 +75,18 @@ ADR-007 and ADR-002.
### Fixed
- **A maintenance script could not find the database the site actually uses.**
`python scripts/export_catalog.py` on a deployed site died with 1045 "Access
denied for user 'root'@'localhost'", naming a user that site does not have.
Nothing loads `.env` for a plain script run: `wsgi.py` does it for the served
app and the `flask` CLI does it for itself, so both reach the real database,
while a bare `python scripts/...` gets neither and falls back to a hardcoded
`root@localhost` URL. The read-only failure is the harmless version - six of
the seven scripts write, and on a box where those fallback credentials happen
to resolve they would have silently rewritten the wrong database. All seven
now load `.env` from the repo root, resolved from the script's own location
rather than the working directory.
- **A search result opened the list it sits in, not the record it found.** A
NOTICE linked to `/notifications`, so clicking the row search had already
identified sent the reader to the list page to find it again by hand. The id