docs(14.2-01): todo for sm-user-plugin commands that need a published database

This commit is contained in:
2026-10-11 17:41:29 +02:00
parent 0b6d757b40
commit ad1fa5abfa

View File

@@ -0,0 +1,12 @@
---
title: Let the sm-user-plugin console commands open their own database
date: 2026-10-07
priority: low
area: sm-user-plugin
---
`user:token:create`, `user:token:list`, `user:token:revoke` (`console/api_tokens.go`) and `user:require-password-change` (`console/require_password_change.go`) only look up a published `*gorm.DB`. The generated application `main` boots the plugins before any command runs, and only `serve`, the `migrate*` commands and the queue commands open and publish the database themselves, so in the real binary these commands stop with `golem15.user: database is not configured` (or `user:require-password-change: database is not configured`). Their tests pass because the test harness publishes the database first.
Found in Phase 14.2 research (gap G1): the same gap stopped `fonoteka:reindex`. Plan 14.2-01 fixed the Fonoteka plugin's own commands (`fonoteka:reindex`, `fonoteka:oauth-client`, `fonoteka:prune-notifications`, and the new `fonoteka:dev-seed`) with a helper that returns the published handle when there is one and otherwise opens `database.dsn` with `lagoon.OpenFromApp` and publishes it with `lagoon.Publish`, so `lagoon.OnDatabase` hooks still run. The seed mints its own API token, so the local stack does not need `user:token:create`.
Suggested fix, in the sm-user-plugin repository: the same published-else-open-and-publish pattern in the user plugin's command helper. It is additive and non-breaking (no route, payload, table, migration ID or config key changes). It is deferred here because sm-user-plugin is a shared core plugin and Phase 14.2 must not modify it; commit and push the plugin first, then bump the submodule pointers in the applications as separate commits. A framework helper (for example in lagoon) that every plugin command can call would remove the duplication; that needs its own decision.