Skip to content

feat: add rowx database command - #161

Merged
mplemay merged 2 commits into
mainfrom
feat/146-database-command
Nov 1, 2026
Merged

mplemay merged 2 commits into
mainfrom
feat/146-database-command

Conversation

@mplemay

@mplemay mplemay commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Closes #146

What

Adds rowx database create | drop [--force] [-y] | reset [--force] [-y] | setup in src/rowx/check/database.py, built on the admin bindings (rowx.postgres._admin) and the migrate run logic.

  • create creates the database named in the URL; if it exists it says so and exits 0.
  • drop confirms on a TTY (y/yes); without a TTY it needs -y, else exits 2 and drops nothing. --force is WITH (FORCE).
  • reset is drop, create, then migrate run. setup is create-if-missing, then migrate run.
  • --database-url and --config on all; --source on reset and setup. Exit 0 or 2, errors redacted as in migrate. Only the database name is printed, never the URL or password.
  • migrate.py is refactored lightly so database reuses it: resolve_target, require_url, run_guarded (shared error mapping and redaction), load_migrator and run_pending (the migrate run call). migrate behaviour is unchanged.
  • reset and setup read and validate the migration files before confirming or touching the database, so a broken migrations/ never leaves a dropped or half-set-up database.

New tests (named)

Unit, src/rowx/__tests__/unit/check/test_database.py: test_parses_flags, test_rejects_flags_that_do_not_apply, test_requires_a_subcommand, test_yes_skips_the_prompt, test_no_tty_without_yes_is_an_error, test_tty_prompt, test_no_database_url_exits_two, test_unreachable_database_exits_two_without_the_password, test_url_without_a_database_name_exits_two.

DB, src/rowx/__tests__/integration/check/test_database.py (uniquely named rowx_dbcli_<hex> databases, always dropped): test_create_twice_exits_zero, test_drop_with_yes, test_drop_without_tty_or_yes_exits_two_and_keeps_the_database, test_drop_confirms_on_a_tty, test_force_drops_a_database_with_a_live_session, test_setup_creates_and_migrates_then_is_idempotent, test_reset_recreates_the_database_with_every_migration_applied, test_reset_without_tty_or_yes_exits_two, test_a_password_is_never_printed, test_invalid_migrations_fail_before_any_database_change.

Wiring edits

  • src/rowx/check/cli.py: registers the database parser and dispatches it (_migrate wrapper becomes the generic _subcommand).
  • src/rowx/check/migrate.py: the shared helpers above.
  • Renamed src/rowx/__tests__/integration/check/test_migrate_cli.py (from feat: add rowx migrate command #160) to test_migrate.py, so integration test files follow AGENTS.md's test_<module>.py rule. No other file references it; the golden files are unchanged.

Spec ambiguities

  • checker.md says create "is an error if it exists", while feat: add rowx database command #146 says it reports that and exits 0. I followed feat: add rowx database command #146 (as sqlx-cli does); the design text should be aligned.
  • Declining the TTY prompt prints Aborted and exits 0 (sqlx-cli behaviour); the design only specifies 0 or 2 for failures.
  • drop of a missing database is a no-op success (the admin binding's contract).
  • reset confirms once, up front, before dropping.
  • feat: add rowx database command #146 names the DB test file test_database_cli.py; it is test_database.py here per AGENTS.md.
  • The DB tests run in fresh, uniquely named databases rather than the schema fixture, since the command under test creates and drops the database itself (testing.md allows "a fresh schema or database" for migration tests).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T02:01:21.028828Z d27125d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d27125d15f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mplemay
mplemay merged commit 9d29be9 into main Nov 1, 2026
3 checks passed
@mplemay
mplemay deleted the feat/146-database-command branch November 1, 2026 02:13
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.

feat: add rowx database command

1 participant