Skip to content

feat: add runtime DB switching with SSH remote support#13

Merged
adsharma merged 5 commits into
LadybugDB:masterfrom
sparkleholic:db-select
May 30, 2026
Merged

feat: add runtime DB switching with SSH remote support#13
adsharma merged 5 commits into
LadybugDB:masterfrom
sparkleholic:db-select

Conversation

@sparkleholic
Copy link
Copy Markdown
Contributor

Changes

  • Add a DB menu in the sidebar that lets users switch the active database at runtime. No server restart neded. Supports file-based (directory + filename) and in-memory modes, and reloads the schema automatically after applying.
  • Add SSH remote mode: mount a remote database directory via sshfs into a local temp path and open it live (read-write, no manual sync). Supports both password auth (via sshpass) and private key file auth. The active SSH config is persisted and pre-populates the modal on re-open; switching away from SSH automatically unmounts the filesystem.
  • Add documentation in README covering runtime DB switching and SSH remote mode requirements (macOS: macFUSE + SSHFS; Linux: sshfs package).

Test

  • Open DB menu, switch between file and in-memory modes
  • Configure SSH remote with password auth (sshpass installed)
  • Configure SSH remote with private key auth

@adsharma
Copy link
Copy Markdown
Contributor

@sparkleholic - have you looked into https://github.com/LadybugDB/bugscope?

These type of features may fit in more naturally there. It also doesn't have the REST API bottleneck. The main use case for this repo is a hard requirement to be browser based.

@adsharma
Copy link
Copy Markdown
Contributor

  • High: src/server/utils/SSHManager.js:75 builds sshfs commands by interpolating user, host, remoteDir,
    privateKeyPath, and port into a shell string. Those values come from the browser via src/server/DBConfig.js:26,
    so this is command injection. Use execFileSync/spawn with argv arrays and validate fields.

  • High: src/server/utils/Database.js:205 closes the active DB before validating the new config and before proving
    the replacement can initialize. If the new path is bad or this.init() throws, the server is left with this.db =
    null and an empty pool. The same risk exists after SSH mount in src/server/DBConfig.js:27. This needs rollback
    or “open new DB first, then swap”.

Add a "DB" sidebar menu that lets users switch the active database
without restarting the server. Supports file-based (directory + filename)
and in-memory modes. The server reconfigures the live connection pool
and the UI reloads the schema automatically after applying.
Add a "Remote (SSH)" option to the DB configuration modal. The server
mounts the remote directory via sshfs into a local temp path and opens
the database from there, so the connection is live (read-write, no
manual sync needed). Supports password auth (requires sshpass) and
private key file auth. The active SSH config (minus password) is
returned by GET /api/db and pre-populates the modal on re-open.
Switching away from SSH mode automatically unmounts the filesystem.
@adsharma adsharma merged commit e80af3a into LadybugDB:master May 30, 2026
1 check passed
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.

2 participants