# Database Commands

Register, list, rename, and remove KuraDB databases with `kura add`, `kura list`, `kura edit`, and `kura remove`.

## Add a database

```bash
kura add my_docs
```

The first argument is used as the name. Runs of whitespace are converted to underscores; an empty result is rejected with status 2. The command refuses a name already in the registry or a target directory that already exists.

On success it creates:

```text
~/.config/kuradb/my_docs/inbox/
~/Kura_my_docs -> ~/.config/kuradb/my_docs/inbox/
```

It then appends an entry with a UTC creation time to `db.json` and prints the directory and link paths. The running daemon does not hot-load the new database, so restart it before searching.

## List databases

```bash
kura list
```

Each line contains a database name and its UTC RFC 3339 creation time, separated by a tab. An empty registry prints `(no registered db)`.

`kura list` reads only the registry. To see which databases the running daemon actually loaded, use [`GET /api/list`](/api-reference#list-databases), which returns both `registered` and `loaded` collections.

## Rename a database

```bash
kura edit my_docs my_archive
```

The command sanitizes both names the same way as `add`, then:

1. Prints `noop` and exits when the old and new names are identical.
2. Rejects an old name that is not registered, a new name that is already registered, or an existing target directory.
3. Renames the database directory.
4. Removes the old `~/Kura_<old>` symlink and creates `~/Kura_<new>`; a symlink failure is reported but does not stop the rename.
5. Updates the registry entry.

Because the daemon keeps its startup-time database map, stop it before a rename and start it again afterwards.

## Remove a database

```bash
kura remove my_archive
```

Removal prints the database directory and symlink, then requires the exact response `yes`. Any other response prints `aborted` and changes nothing. Confirmation permanently removes the database directory, removes the home path only when it is a symlink (a regular file or directory there is skipped with a warning), and deletes the registry entry.

This operation deletes the authoritative SQLite database. Back up required data before confirming.
