Skip to content

postgres create-branch: add --ttl and --no-expiry flags - #6313

Merged
andrewnester merged 6 commits into
databricks:mainfrom
scott-mead-db:postgres-create-branch-ttl
Sep 28, 2026
Merged

andrewnester merged 6 commits into
databricks:mainfrom
scott-mead-db:postgres-create-branch-ttl

Conversation

@scott-mead-db

@scott-mead-db scott-mead-db commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Creating a Lakebase branch requires an expiration (no-expiry is valid, but required). Today, this is not documented and only possible via a --json spec which is unintuitive and creates friction for users.

Previous syntax:

databricks postgres create-branch projects/my-project new-branch-name \
     --json '{"spec": {"no_expiry": true}}'

New syntax:

databricks postgres create-branch projects/my-project new-branch-name --no-expiry
  # or
databricks postgres create-branch projects/my-project new-branch-name --ttl 7d

This PR adds two switches to the databricks postgres create-branch command:

--ttl sets spec.ttl; accepts the REST API form (604800s),
a Go duration (168h), or day/week units (7d, 3w)
--no-expiry sets spec.no_expiry

One of --ttl, --no-expiry, or a spec expiration in --json is required; they are mutually exclusive. The flags are wired through the existing createBranchOverrides hook in a PreRunE that shapes req.Branch.Spec before the generated RunE merges --json and calls the API, so the generated command and the SDK are untouched.

Co-authored-by: Isaac

Setting a branch's expiration on `databricks postgres create-branch`
previously required a hand-written `--json` spec. Add two convenience
flags:

  --ttl <duration>   sets spec.ttl; accepts the REST API form (604800s),
                     a Go duration (168h), or day/week units (7d, 3w)
  --no-expiry        sets spec.no_expiry

One of --ttl, --no-expiry, or a spec expiration in --json is required;
they are mutually exclusive. The flags are wired through the existing
createBranchOverrides hook in a PreRunE that shapes req.Branch.Spec
before the generated RunE merges --json and calls the API, so the
generated command and the SDK are untouched.

Co-authored-by: Isaac
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for approval

Based on git history, these people are best suited to review:

  • @janniklasrose -- recent work in .nextchanges/cli/

Eligible reviewers: @andrewnester, @anton-107, @denik, @lennartkats-db, @pietern, @rclarey, @renaudhartert-db, @rugpanov, @shreyas-goenka, @simonfaltum

Suggestions based on git history. See OWNERS for ownership rules.

@scott-mead-db

Copy link
Copy Markdown
Contributor Author

Asking for a review @andrewnester

@scott-mead-db

Copy link
Copy Markdown
Contributor Author

@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: c16a3d1

Run: 32345462596

Env 🟨​KNOWN 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 286 1160 5:14
💚​ aws windows 4 4 288 1158 8:57
💚​ azure linux 4 4 285 1160 5:15
💚​ azure windows 4 4 287 1158 7:23
🟨​ gcp linux 1 1 4 286 1160 8:04
🟨​ gcp windows 1 1 4 288 1158 9:36
8 interesting tests: 4 SKIP, 3 RECOVERED, 1 KNOWN
Test Name aws linux aws windows azure linux azure windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 🟨​K 🟨​K
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R
Top 6 slowest tests (at least 2 minutes):
duration env testname
8:48 aws windows TestAccept
7:14 azure windows TestAccept
7:05 gcp windows TestAccept
3:51 aws linux TestAccept
3:50 gcp linux TestAccept
3:46 azure linux TestAccept

Comment thread acceptance/cmd/workspace/postgres/create-branch/script
Comment thread acceptance/cmd/workspace/postgres/create-branch/script

title "the --no-wait path still works alongside --no-expiry"
$CLI postgres create-branch projects/acc-proj branch-nowait --no-expiry --no-wait > LOG.nowait 2>&1

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.

What happens if you pass something like --json '{\"spec\":{\"ttl\":\"\"}}'?

@scott-mead-db scott-mead-db Aug 24, 2026 •

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.

The SDK will error out with: Error: invalid character 't' after top-level value

Comment thread cmd/workspace/postgres/overrides.go Outdated
if len(raw) == 0 {
return false
}
var probe struct {

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.

Why a separate type instead of SDK one? This decodes differently from convert.Normalize, and if a future SDK bump renames/retypes a BranchSpec field, neither the compiler nor tests catch the drift which lead to error / unexpected behaviour

scott-mead-db and others added 2 commits August 24, 2026 12:20
- Check for a --json expiration by decoding into the SDK BranchSpec, not a
  hand-rolled struct, so it matches the real decode and won't drift on a rename.
- --no-expiry with a --json that sets spec.no_expiry is now a conflict, not a
  silent override.
- Tests for the conflict, malformed json, and an empty ttl.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@andrewnester
andrewnester self-requested a review September 4, 2026 08:39
@@ -0,0 +1 @@
Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required.

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.

Suggested change
Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required.
* Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required.

@andrewnester
andrewnester requested a review from a team as a code owner September 28, 2026 14:13
@andrewnester
andrewnester merged commit eae80e0 into databricks:main Sep 28, 2026
13 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 6313
  • Commit SHA: da9cf3dd36c369e92693bfa449ee4f6f9467018f

Checks will be approved automatically on success.

deco-sdk-tagging Bot added a commit that referenced this pull request Sep 30, 2026
## Release v1.19.0

### CLI

 * Honor `CLAUDE_CONFIG_DIR` in `aitools` commands. ([#6838](#6838))
 * Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required. ([#6313](#6313))
 * `databricks ssh connect` serverless sessions now provide Claude Code and Codex configured with Unity Gateway out of the box. ([#6885](#6885))

### AI Runtime

 * Add `databricks air images push` (Preview) to configure Docker authentication and push container images to Databricks Artifact Registry. ([#6869](#6869))
 * `air run` now grants the configured `permissions` on the MLflow experiment as well as the job. ([#6870](#6870))

### Bundles

 * Add libraries field to clusters. ([#6831](#6831))
 * Error out when a configured `workspace_id` does not match the connected workspace, instead of silently using it in resource URLs emitted by `bundle summary`. ([#6754](#6754))
 * Fix spurious recreation of Lakebase (Postgres) branches, roles, and catalogs when the referenced project is updated in place: an in-place project change (e.g. `display_name`) no longer forces a delete + create of resources that reference the project's or branch's `name`. ([#6865](#6865))
 * Direct engine now detects and applies an explicitly configured integer zero (e.g. `gcp_attributes.local_ssd_count: 0`) added to a resource first deployed without the field. ([#6867](#6867))
 * Migrate existing Terraform deployment state to the direct engine before deploying (previously done after a Terraform deploy), so the deploy runs on the direct engine. ([#6749](#6749))
 * The `postgres_snapshot_schedules` resource (introduced in [v1.16.0](https://github.com/databricks/cli/releases/tag/v1.16.0)) is now marked Beta and is no longer available in PyDABs, matching the other `postgres_*` resources; configure it in YAML instead. ([#6887](#6887))
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