Skip to content

feat(app): add commands to link, unlink and replace an app's database - #1971

Merged
martin-helmich merged 3 commits into
masterfrom
feat/1969-app-database-commands
Jul 21, 2026
Merged

martin-helmich merged 3 commits into
masterfrom
feat/1969-app-database-commands

Conversation

@martin-helmich

Copy link
Copy Markdown
Member

Managing an app installation's linked database (link / unlink / replace) was previously only possible via the raw HTTP API. This adds dedicated mw subcommands under a new app database command group.

Commands added

  • mw app database link <installation-id> --database-id <id> [--purpose primary|cache|custom] --admin-user-id <id>
    Wraps the app-link-database operation (apiClient.app.linkDatabase). Always includes databaseUserIds.admin in the payload, since the API rejects the call without it even though the schema only marks databaseId and purpose as required.
  • mw app database unlink <installation-id> --database-id <id>
    Wraps app-unlink-database (apiClient.app.unlinkDatabase). Built on DeleteBaseCommand, so it asks for confirmation (skippable via -f/--force).
  • mw app database replace <installation-id> --old-database-id <id> --new-database-id <id> --admin-user-id <id>
    Wraps app-replace-database (apiClient.app.replaceDatabase).

The "set database users" operation was left out for now as it is lower priority.

Notes

  • The app installation is taken as a positional argument (installation-id), consistent with mw app uninstall, and supports short IDs (a-XXXXXX) and CLI context.
  • --purpose defaults to primary.
  • The server-side databaseUserIDs vs databaseUserIds casing bug mentioned in the issue is an API-side concern and is out of scope here.

Closes #1969

🤖 Generated with Claude Code

martin-helmich and others added 3 commits July 2, 2026 11:19
Adds `mw app database link | unlink | replace` so managing an app
installation's linked database no longer requires calling the raw HTTP
API.

- `link` wraps the `app-link-database` operation and always sends
  `databaseUserIds.admin`, which the API requires in practice.
- `unlink` wraps `app-unlink-database`.
- `replace` wraps `app-replace-database`.

Closes #1969

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The app database commands no longer require full database UUIDs:

- link/replace now accept a database name (resolved against the
  project's MySQL and Redis databases) in addition to a UUID.
- unlink and replace determine the currently linked database from the
  app installation automatically, so the old database ID no longer has
  to be supplied. An optional --purpose flag disambiguates when several
  databases are linked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@martin-helmich
martin-helmich merged commit 20bbbcd into master Jul 21, 2026
11 checks passed
@martin-helmich
martin-helmich deleted the feat/1969-app-database-commands branch July 21, 2026 09:15
mittwald-machine added a commit that referenced this pull request Jul 21, 2026
# [1.21.0](v1.20.3...v1.21.0) (2026-07-21)

### Bug Fixes

* **database:** adapt MySQL user update to @mittwald/api-client 4.420 ([#2020](#2020)) ([d1980b9](d1980b9)), closes [#2017](#2017)

### Features

* **app:** add commands to link, unlink and replace an app's database ([#1971](#1971)) ([20bbbcd](20bbbcd)), closes [#1969](#1969)
* **database:** add "database mysql upgrade" command ([#2005](#2005)) ([1265923](1265923))
* **deploy:** build and push early exit for experimental deploy ([#2021](#2021)) ([225c8e0](225c8e0)), closes [#1990](#1990)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No CLI command to link/unlink an app installation's database (API-only)

2 participants