Skip to content

feat(nativedb): add native database cli support - #519

Open
rAJ-2301 wants to merge 4 commits into
develfrom
feat/native-db-cli-support
Open

feat(nativedb): add native database cli support#519
rAJ-2301 wants to merge 4 commits into
develfrom
feat/native-db-cli-support

Conversation

@rAJ-2301

Copy link
Copy Markdown
Contributor

Adds rio database command group for managing database resources on the platform.

New Commands

  • rio database list — list all databases in the project (supports --wide)
  • rio database inspect — inspect a database resource in YAML/JSON
  • rio database delete — delete one or more databases by name or regex pattern (supports --all, parallel workers)
  • rio database versions — list supported database engine versions
  • rio database backup list / inspect / delete / restore — manage database backups

Apply Support

  • Registered Database as a supported kind in rio apply
  • Added riocli/apply/manifests/database.yaml as a sample manifest template

Copilot AI review requested due to automatic review settings April 16, 2026 09:43
@rAJ-2301
rAJ-2301 requested review from a team as code owners April 16, 2026 09:43
@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown

🤖 Pull Request Artifacts (#25847513829) 🎉

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds native database management support to the rio CLI by introducing a new rio database command group and registering Database as an rio apply-supported kind (backed by new SDK v2 database APIs).

Changes:

  • Introduces rio database subcommands for listing, inspecting, deleting databases, listing engine versions, and managing backups (list/inspect/delete/restore).
  • Registers Database in rio apply and adds a sample database.yaml manifest template.
  • Switches rapyuta-io-sdk-v2 dependency to a Git branch providing native DB client support.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Locks rapyuta-io-sdk-v2 to a Git source for DB API support.
pyproject.toml Updates dependency spec to use the Git-based rapyuta-io-sdk-v2.
riocli/model/base.py Improves missing-name validation error message.
riocli/database/init.py Adds database Click group and wires subcommands.
riocli/database/list.py Implements rio database list (--wide).
riocli/database/inspect.py Implements rio database inspect (YAML/JSON).
riocli/database/delete.py Implements rio database delete (pattern/all, parallel workers).
riocli/database/versions.py Implements rio database versions.
riocli/database/backup.py Implements rio database backup subcommands.
riocli/database/util.py Adds helpers for selecting/printing databases for confirmation.
riocli/database/model.py Adds Database apply model for create/delete.
riocli/bootstrap.py Registers database group at the top-level CLI.
riocli/apply/util.py Registers Database in KIND_TO_CLASS for apply.
riocli/apply/manifests/database.yaml Adds sample Database manifest template.

Comment thread riocli/bootstrap.py
Comment on lines 176 to +179
cli.add_command(role)
cli.add_command(service_account)
cli.add_command(permission)
cli.add_command(database)

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New rio database command group is added to the root CLI, but there are no corresponding tests under tests/ (no database mentions in tests/main), while other command groups have integration/RBAC coverage. Add at least basic CLI tests (list/inspect/delete/backup/versions) and apply-kind coverage for Database to prevent regressions.

Copilot uses AI. Check for mistakes.
Comment thread riocli/database/model.py

@override
def list_dependencies(self) -> list[str] | None:
return None

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database.list_dependencies() always returns None, so rio apply can't order Database creation after the referenced primary/standby devices. Given the manifest schema references spec.postgres.primary.deviceName (and possibly standby devices), this can cause apply to attempt database creation before its device resources exist. Consider returning a dependency list (e.g., device:<name>) derived from the referenced deviceName fields (or delegating to the SDK model’s list_dependencies() if available).

Suggested change
return None
sdk_list_dependencies = getattr(self._obj, "list_dependencies", None)
if callable(sdk_list_dependencies):
sdk_dependencies = sdk_list_dependencies()
if sdk_dependencies:
return sdk_dependencies
def _get_value(obj, key):
if obj is None:
return None
if isinstance(obj, dict):
return obj.get(key)
return getattr(obj, key, None)
def _append_device_dependency(dependencies: list[str], device_ref) -> None:
device_name = _get_value(device_ref, "deviceName")
if device_name:
dependency = f"device:{device_name}"
if dependency not in dependencies:
dependencies.append(dependency)
dependencies: list[str] = []
spec = _get_value(self, "spec")
postgres = _get_value(spec, "postgres")
_append_device_dependency(dependencies, _get_value(postgres, "primary"))
standby = _get_value(postgres, "standby")
if isinstance(standby, list):
for standby_device in standby:
_append_device_dependency(dependencies, standby_device)
else:
_append_device_dependency(dependencies, standby)
standbys = _get_value(postgres, "standbys")
if isinstance(standbys, list):
for standby_device in standbys:
_append_device_dependency(dependencies, standby_device)
else:
_append_device_dependency(dependencies, standbys)
return dependencies or None

Copilot uses AI. Check for mistakes.
Comment thread pyproject.toml
@rAJ-2301
rAJ-2301 force-pushed the feat/native-db-cli-support branch from 34ea9f4 to 3afbbc3 Compare May 8, 2026 09:19
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.

3 participants