Skip to content

feat: use database as primary name for new db subcommands#8176

Merged
pieh merged 7 commits intomainfrom
michalpiechowiak/run-2792-rename-cli-commands-to-database-with-db-aliases
Apr 22, 2026
Merged

feat: use database as primary name for new db subcommands#8176
pieh merged 7 commits intomainfrom
michalpiechowiak/run-2792-rename-cli-commands-to-database-with-db-aliases

Conversation

@pieh
Copy link
Copy Markdown
Contributor

@pieh pieh commented Apr 21, 2026

🎉 Thanks for submitting a pull request! 🎉

Summary

Swaps db command (with database alias) for the database command (with db alias). All previously working commands will continue to work. Main impact is what --help would print


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Chores

    • Adjusted CLI command registration to present the appropriate top-level name per mode (standard "db" vs experimental "database") and updated examples accordingly.
  • Documentation

    • Standardized user-facing examples, hints, and interactive client name to the "database" namespace where applicable.
  • Tests

    • Updated unit test expectations to match the revised CLI messaging.

Walkthrough

The PR updates CLI command registration and user-facing examples/messages for the database CLI. src/commands/database/database.ts now constructs the top-level command separately per branch: when EXPERIMENTAL_NETLIFY_DB_ENABLED !== '1' it registers db (alias database) with a reduced examples list; when enabled it registers database (alias db) and updates CLI-level examples to the netlify database ... namespace. src/commands/database/db-status.ts and src/commands/database/util/meta-commands.ts update displayed strings (switching dbdatabase and renaming the interactive client). Tests in tests/unit/commands/database/db-status.test.ts were updated to match the new messages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: swapping the primary command name from 'db' to 'database' for database subcommands.
Description check ✅ Passed The description is directly related to the changeset, explaining that the PR swaps 'db' command for 'database' as primary with reciprocal aliases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch michalpiechowiak/run-2792-rename-cli-commands-to-database-with-db-aliases

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

📊 Benchmark results

Comparing with b5b60e3

  • Dependency count: 1,061 (no change)
  • Package size: 355 MB ⬇️ 0.00% decrease vs. b5b60e3
  • Number of ts-expect-error directives: 356 (no change)

@pieh pieh force-pushed the michalpiechowiak/run-2792-rename-cli-commands-to-database-with-db-aliases branch from 47a7ff9 to e9f59b1 Compare April 21, 2026 10:38
@pieh pieh changed the title feat: rename db command to database, keep db as alias feat: use database as primary name for new db subcommands Apr 21, 2026
@pieh pieh marked this pull request as ready for review April 21, 2026 10:56
@pieh pieh requested a review from a team as a code owner April 21, 2026 10:56
Comment on lines +14 to +19
const dbCommand = program
.command('db')
.alias('database')
.description(`Provision a production ready Postgres database with a single command`)
.addExamples(['netlify db status', 'netlify db init', 'netlify db init --help'])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To keep previous db command as is - this totally separate dbCommand for both code paths.

Otherwise there would be 3 ternary checking EXPERIMENTAL_NETLIFY_DB_ENABLED (for command, alias and currently existing addExamples

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/database/db-status.ts`:
- Around line 48-49: Tests still assert the old CLI strings (e.g., "netlify db
connect", "netlify db status --show-credentials", "netlify db migrations
apply"); update those assertions to expect the renamed command format using
"database" (e.g., "database connect", "database status --show-credentials",
"database migrations apply"). Search test assertions that reference the old
strings and replace them with the new ones (or update expected values passed to
formatCommand calls) so they match the producer code that now calls
secondary(`Run ${formatCommand('database connect')}`) and similar formatCommand
usages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd718753-c204-45c8-95cd-0e9b04318534

📥 Commits

Reviewing files that changed from the base of the PR and between e9f59b1 and 99f12d6.

📒 Files selected for processing (2)
  • src/commands/database/db-status.ts
  • src/commands/database/util/meta-commands.ts
✅ Files skipped from review due to trivial changes (1)
  • src/commands/database/util/meta-commands.ts

Comment thread src/commands/database/db-status.ts
eduardoboucas
eduardoboucas previously approved these changes Apr 21, 2026
Comment thread src/commands/database/database.ts Outdated
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/database/database.ts`:
- Around line 74-77: Test coverage is missing for the alias routing of the
database command when EXPERIMENTAL_NETLIFY_DB_ENABLED=1; add an integration test
similar to tests/integration/commands/build/build-program.test.ts that starts
the CLI with the env var set and asserts that invoking "netlify db status" (and
other subcommands) dispatches to the database command implementation defined by
program.command('database') / dbCommand.alias('db'); the test should spawn the
CLI or invoke the program entry, set EXPERIMENTAL_NETLIFY_DB_ENABLED=1, run "db
status" and verify the expected output/exit code to ensure alias routing works
end-to-end.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e7c0d73-5d44-4916-8c36-86ecc8a78bf6

📥 Commits

Reviewing files that changed from the base of the PR and between cc9d5ea and 16b9fc2.

📒 Files selected for processing (1)
  • src/commands/database/database.ts

Comment on lines +74 to +77
const dbCommand = program
.command('database')
.alias('db')
.description(`Provision a production ready Postgres database with a single command`)
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Inspect database command tests for coverage that exercises the experimental `db` alias.
# Expected: At least one test sets EXPERIMENTAL_NETLIFY_DB_ENABLED=1 and invokes a `netlify db ...`
# command such as `db status`, `db connect`, `db reset`, or `db migrations ...`.

rg -n -C3 --type=ts \
  'EXPERIMENTAL_NETLIFY_DB_ENABLED|netlify db (status|connect|reset|migrations)|\bdb (status|connect|reset|migrations)\b' \
  tests src/commands/database

Repository: netlify/cli

Length of output: 4309


🏁 Script executed:

fd -type f -name "*database*.test.ts" tests/

Repository: netlify/cli

Length of output: 225


🏁 Script executed:

rg -n "command.*database|netlify database" tests/ --type ts | head -20

Repository: netlify/cli

Length of output: 2710


🏁 Script executed:

grep -r "EXPERIMENTAL_NETLIFY_DB_ENABLED" tests/unit/commands/database/ --include="*.ts"

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

head -100 tests/unit/commands/database/db-status.test.ts

Repository: netlify/cli

Length of output: 3412


🏁 Script executed:

find tests -name "*database*.test.ts" -type f

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

grep -r "\.command.*database\|\.alias.*db" tests/ --include="*.ts" -n

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

grep -r "process.env.EXPERIMENTAL_NETLIFY_DB_ENABLED" tests/ --include="*.ts" -A 3 -B 3

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

ls -la tests/unit/commands/database/

Repository: netlify/cli

Length of output: 601


🏁 Script executed:

ls -la tests/integration/commands/ | grep -i database

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

rg "createDatabaseCommand|program\.command.*database" tests/ -A 5

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

rg "db.*status|database.*status" tests/unit/commands/database/ -n | head -5

Repository: netlify/cli

Length of output: 438


🏁 Script executed:

cat tests/unit/commands/database/db-status.test.ts | grep -A 10 "import.*statusDb"

Repository: netlify/cli

Length of output: 521


🏁 Script executed:

rg "test.*\(.*db.*\)" tests/unit/commands/database/db-status.test.ts | head -10

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

rg "program.*command|createDatabaseCommand" src/commands/database/database.ts -A 2 -B 2

Repository: netlify/cli

Length of output: 287


🏁 Script executed:

find tests -name "*.test.ts" -exec grep -l "EXPERIMENTAL\|alias" {} \; | head -10

Repository: netlify/cli

Length of output: 321


🏁 Script executed:

rg "test\(" tests/integration/commands/dev/dev.programmatic-netlify-dev.test.ts | grep -i db

Repository: netlify/cli

Length of output: 256


🏁 Script executed:

ls -la tests/integration/commands/dev/

Repository: netlify/cli

Length of output: 1386


🏁 Script executed:

grep -r "netlify database\|netlify db" tests/integration/commands/ --include="*.ts" -n | head -10

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

rg "program.*baseCommand|BaseCommand" tests/ -l | head -5

Repository: netlify/cli

Length of output: 283


🏁 Script executed:

cat tests/integration/commands/build/build-program.test.ts | head -50

Repository: netlify/cli

Length of output: 1522


🏁 Script executed:

rg "database|alias" tests/integration/commands/build/build-program.test.ts

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

find tests -name "*program*.test.ts" -type f

Repository: netlify/cli

Length of output: 177


🏁 Script executed:

grep -A 20 "createBuildCommand" tests/integration/commands/build/build-program.test.ts | head -30

Repository: netlify/cli

Length of output: 1194


🏁 Script executed:

rg "createDatabaseCommand" tests/ --include="*.ts"

Repository: netlify/cli

Length of output: 496


🏁 Script executed:

ls -la tests/integration/commands/ | grep database

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

grep -r "const program\|new BaseCommand" tests/integration/commands/build/ --include="*.ts" -A 3

Repository: netlify/cli

Length of output: 935


🏁 Script executed:

rg "createDatabaseCommand" src/ -l

Repository: netlify/cli

Length of output: 140


🏁 Script executed:

grep -r "createDatabaseCommand\|createBuildCommand\|createDeployCommand" src/commands/main.ts -A 2 -B 2

Repository: netlify/cli

Length of output: 1119


🏁 Script executed:

find tests -name "*database*.test.ts" -path "*/integration/*" -type f

Repository: netlify/cli

Length of output: 37


🏁 Script executed:

grep -r "createDatabaseCommand\|parseAsync.*database\|parseAsync.*db" tests/ -n

Repository: netlify/cli

Length of output: 37


Add integration test for the db alias dispatch.

No test coverage exists for the database command routing when EXPERIMENTAL_NETLIFY_DB_ENABLED=1 is set. While unit tests verify individual command implementations, none test the alias dispatch. Add an integration test following the pattern in tests/integration/commands/build/build-program.test.ts to ensure netlify db status (and other subcommands) correctly routes through the alias when the experimental flag is enabled.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/database/database.ts` around lines 74 - 77, Test coverage is
missing for the alias routing of the database command when
EXPERIMENTAL_NETLIFY_DB_ENABLED=1; add an integration test similar to
tests/integration/commands/build/build-program.test.ts that starts the CLI with
the env var set and asserts that invoking "netlify db status" (and other
subcommands) dispatches to the database command implementation defined by
program.command('database') / dbCommand.alias('db'); the test should spawn the
CLI or invoke the program entry, set EXPERIMENTAL_NETLIFY_DB_ENABLED=1, run "db
status" and verify the expected output/exit code to ensure alias routing works
end-to-end.

@pieh pieh enabled auto-merge (squash) April 22, 2026 13:37
@pieh pieh merged commit 40e56cf into main Apr 22, 2026
104 of 105 checks passed
@pieh pieh deleted the michalpiechowiak/run-2792-rename-cli-commands-to-database-with-db-aliases branch April 22, 2026 14:47
sean-roberts pushed a commit that referenced this pull request Apr 22, 2026
🤖 I have created a release *beep* *boop*
---


## [25.2.0](v25.1.1...v25.2.0)
(2026-04-22)


### Features

* use database as primary name for new db subcommands
([#8176](#8176))
([40e56cf](40e56cf))


### Bug Fixes

* don't cause fatal issues when doing update checks inside of agent
sandbox ([#8186](#8186))
([acaf478](acaf478))
* filter out intentional user-input errors from error-reporting-lamda
([#8188](#8188))
([b5b60e3](b5b60e3))
* improve reliability of anon deploys
([#8170](#8170))
([95b5e52](95b5e52))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: token-generator-app[bot] <82042599+token-generator-app[bot]@users.noreply.github.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.

2 participants