Skip to content

feat: support NETLIFY_DB_BRANCH env var in db status command#8174

Merged
eduardoboucas merged 1 commit intomainfrom
feat/db-status-env
Apr 20, 2026
Merged

feat: support NETLIFY_DB_BRANCH env var in db status command#8174
eduardoboucas merged 1 commit intomainfrom
feat/db-status-env

Conversation

@eduardoboucas
Copy link
Copy Markdown
Member

Follow-up to #8173.

@eduardoboucas eduardoboucas requested a review from a team as a code owner April 20, 2026 19:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for configuring the remote database branch via the NETLIFY_DB_BRANCH environment variable
    • CLI flag --branch takes precedence when both the environment variable and flag are set
    • Updated error messaging for remote branch targeting
  • Tests

    • Added comprehensive tests for environment variable behavior and CLI flag precedence

Walkthrough

This pull request adds support for specifying the remote database branch via the NETLIFY_DB_BRANCH environment variable in the statusDb command. The implementation introduces a derived branch variable that defaults to options.branch but falls back to the environment variable when the CLI flag is not provided. This branch variable is then used throughout the function for fetching the connection string, retrieving applied migrations, and displaying branch information. Corresponding unit tests verify that the environment variable is properly used and that the CLI flag takes precedence when both are supplied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for the NETLIFY_DB_BRANCH environment variable in the db status command, which matches the changeset.
Description check ✅ Passed The description references a follow-up to PR #8173, which provides context that relates to the changeset, though minimal detail is given.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 feat/db-status-env

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

@github-actions
Copy link
Copy Markdown

📊 Benchmark results

Comparing with 9bccaf9

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

Copy link
Copy Markdown

@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/status-db.ts`:
- Around line 364-365: Remove the explanatory inline comment that duplicates
behavior for branch resolution; delete the comment line preceding the
declaration so the code reads simply as const branch = options.branch ??
process.env.NETLIFY_DB_BRANCH (no comment needed). Locate the comment that says
"`--branch` can also be supplied via the NETLIFY_DB_BRANCH env var." immediately
above the branch assignment and remove it, leaving the assignment as the
self-explanatory implementation.
🪄 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: 35ab0acf-12c5-4eee-b4f9-d2005e010900

📥 Commits

Reviewing files that changed from the base of the PR and between 9bccaf9 and 52d375f.

📒 Files selected for processing (2)
  • src/commands/database/status-db.ts
  • tests/unit/commands/database/status-db.test.ts

Comment on lines +364 to +365
// `--branch` can also be supplied via the NETLIFY_DB_BRANCH env var.
const branch = options.branch ?? process.env.NETLIFY_DB_BRANCH
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove explanatory inline behavior comment.

Line 364-365 documents what the code does; this should be expressed by code only.

Suggested cleanup
-  // `--branch` can also be supplied via the NETLIFY_DB_BRANCH env var.
   const branch = options.branch ?? process.env.NETLIFY_DB_BRANCH

As per coding guidelines, **/*.{ts,tsx,js,jsx}: Never write comments on what the code does; make the code clean and self-explanatory instead.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// `--branch` can also be supplied via the NETLIFY_DB_BRANCH env var.
const branch = options.branch ?? process.env.NETLIFY_DB_BRANCH
const branch = options.branch ?? process.env.NETLIFY_DB_BRANCH
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/database/status-db.ts` around lines 364 - 365, Remove the
explanatory inline comment that duplicates behavior for branch resolution;
delete the comment line preceding the declaration so the code reads simply as
const branch = options.branch ?? process.env.NETLIFY_DB_BRANCH (no comment
needed). Locate the comment that says "`--branch` can also be supplied via the
NETLIFY_DB_BRANCH env var." immediately above the branch assignment and remove
it, leaving the assignment as the self-explanatory implementation.

@eduardoboucas eduardoboucas merged commit 5647420 into main Apr 20, 2026
69 checks passed
@eduardoboucas eduardoboucas deleted the feat/db-status-env branch April 20, 2026 19:58
eduardoboucas pushed a commit that referenced this pull request Apr 21, 2026
🤖 I have created a release *beep* *boop*
---


## [25.1.0](v25.0.1...v25.1.0)
(2026-04-21)


### Features

* add `db migrations reset` command
([#8177](#8177))
([3dd0f38](3dd0f38))
* add `db status` command
([#8173](#8173))
([9bccaf9](9bccaf9))
* Add deploy_source to CLI deploy requests (EX-2032)
([#8155](#8155))
([289933d](289933d))
* restructure db command files
([#8175](#8175))
([794c2e0](794c2e0))
* support `NETLIFY_DB_BRANCH` env var in `db status` command
([#8174](#8174))
([5647420](5647420))

---
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