Skip to content

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

Open
martin-helmich wants to merge 3 commits into
masterfrom
feat/1969-app-database-commands
Open

feat(app): add commands to link, unlink and replace an app's database#1971
martin-helmich wants to merge 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>
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)

1 participant