Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
222eaa4
Bump databricks-sdk-go from v0.175.0 to v0.177.0
janniklasrose Aug 31, 2026
686d31b
Add postgres_snapshot_schedules bundle resource
janniklasrose Aug 31, 2026
c57ed62
Remove redundant snapshot_schedules acceptance subtests
janniklasrose Sep 1, 2026
48d3fa7
Add snapshotScheduleName helper to normalize a trailing slash
janniklasrose Sep 1, 2026
9970a2c
Assert no drift after removing the snapshot schedule
janniklasrose Sep 1, 2026
120176f
task generate-check
janniklasrose Sep 1, 2026
4400109
Merge remote-tracking branch 'origin/main' into janniklasrose/postgre…
janniklasrose Sep 8, 2026
877b6ae
Wire postgres_snapshot_schedules into resource exhaustiveness checks
janniklasrose Sep 8, 2026
c032faa
Fix changelog fragment format for postgres_snapshot_schedules
janniklasrose Sep 8, 2026
2aadf86
Resolve postgres_snapshot_schedules URL to the branch restore page
janniklasrose Sep 8, 2026
6a4da27
Build snapshot schedule URL via workspaceurls helper
janniklasrose Sep 8, 2026
7b40ce7
Fix resource-type list tests and derive snapshot URL from ID
janniklasrose Sep 8, 2026
adc3126
Remove postgres_snapshot_schedules from the noURL allowlist
janniklasrose Sep 8, 2026
31f4012
Merge remote-tracking branch 'origin/main' into janniklasrose/postgre…
janniklasrose Sep 8, 2026
21c12cc
Give PostgresSnapshotScheduleConfig a value-receiver MarshalJSON
janniklasrose Sep 8, 2026
77ae3b5
Remove URL handling from postgres_snapshot_schedules
janniklasrose Sep 8, 2026
0ae783f
Only allow snapshot schedules on the root branch
janniklasrose Sep 8, 2026
1cb15f6
Expose the snapshot schedule name via GetName
janniklasrose Sep 8, 2026
d985cb0
Merge remote-tracking branch 'origin/main' into janniklasrose/postgre…
janniklasrose Sep 8, 2026
ea32dbc
Regenerate PyDABs for postgres_snapshot_schedules
janniklasrose Sep 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/bundles/postgres-snapshot-schedules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add the `postgres_snapshot_schedules` bundle resource for managing a Lakebase Postgres branch's automatic-snapshot schedule (direct deployment engine only). ([#6449](https://github.com/databricks/cli/pull/6449))
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundle:
name: test-bundle

resources:
postgres_snapshot_schedules:
schedule1:
branch: projects/test-project/branches/main
schedule:
- daily_schedule:
hour: 3
retention: "604800s"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

>>> [CLI] bundle deployment bind schedule1 projects/test-project/branches/main/snapshot-schedule --auto-approve
Successfully bound postgres_snapshot_schedule with an id 'projects/test-project/branches/main/snapshot-schedule'
Run 'bundle deploy' to deploy changes to your workspace

>>> [CLI] bundle summary
Name: test-bundle
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
Resources:
Postgres snapshot schedules:
schedule1:
Name: projects/test-project/branches/main/snapshot-schedule
URL: (not deployed)

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.

Is it expected that it shows not deployed here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

there's no URL - we show the same for other resources that don't have a URL, so out of scope here but I'll take a look if we can return something else (like "not supported")


>>> [CLI] bundle deployment unbind schedule1

>>> [CLI] bundle summary
Name: test-bundle
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
Resources:
Postgres snapshot schedules:
schedule1:
Name:
URL: (not deployed)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SCHEDULE_NAME="projects/test-project/branches/main/snapshot-schedule"
trace $CLI bundle deployment bind schedule1 "${SCHEDULE_NAME}" --auto-approve
trace $CLI bundle summary

trace $CLI bundle deployment unbind schedule1
trace $CLI bundle summary
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Cloud = false

# The snapshot schedule was added to the Postgres API in databricks-sdk-go
# v0.177.0, which the pinned Terraform provider does not yet include, so there is
# no databricks_..._snapshot_schedule resource. Run the direct engine only.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]

Ignore = [
".databricks"
]

[[Server]]
Pattern = "GET /api/2.0/postgres/projects/test-project/branches/main/snapshot-schedule"
Response.Body = '''
{
"name": "projects/test-project/branches/main/snapshot-schedule",
"schedule": [
{
"daily_schedule": {
"hour": 3
},
"retention": "604800s"
}
]
}
'''
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
bundle:
name: test-bundle-$UNIQUE_NAME

resources:
postgres_projects:
project:
project_id: test-pg-project-$UNIQUE_NAME
display_name: Test Postgres Project

postgres_branches:
foo:
parent: ${resources.postgres_projects.project.name}
branch_id: test-branch-$UNIQUE_NAME
no_expiry: true

postgres_snapshot_schedules:
foo:
branch: ${resources.postgres_branches.foo.name}
schedule:
- daily_schedule:
hour: 3
retention: "604800s"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
bundle:
name: my_project

sync: {paths: []} # don't need to copy files

python:
resources:
- "resources:load_resources"
mutators:
- "mutators:update_postgres_snapshot_schedule"

resources:
postgres_snapshot_schedules:
my_snapshot_schedule_1:
branch: "projects/test-project/branches/production"
schedule:
- retention: "604800s"
daily_schedule:
hour: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dataclasses import replace

from databricks.bundles.core import postgres_snapshot_schedule_mutator
from databricks.bundles.postgres_snapshot_schedules import PostgresSnapshotSchedule


@postgres_snapshot_schedule_mutator
def update_postgres_snapshot_schedule(
schedule: PostgresSnapshotSchedule,
) -> PostgresSnapshotSchedule:
assert isinstance(schedule.branch, str)

return replace(schedule, branch=f"{schedule.branch} (updated)")

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json
{
"experimental": {
"python": {
"mutators": [
"mutators:update_postgres_snapshot_schedule"
],
"resources": [
"resources:load_resources"
]
}
},
"resources": {
"postgres_snapshot_schedules": {
"my_snapshot_schedule_1": {
"branch": "projects/test-project/branches/production (updated)",
"schedule": [
{
"daily_schedule": {
"hour": 3
},
"retention": "604800s"
}
]
},
"my_snapshot_schedule_2": {
"branch": "projects/other-project/branches/production (updated)",
"schedule": [
{
"daily_schedule": {
"hour": 5
},
"retention": "604800s"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from databricks.bundles.core import Resources


def load_resources() -> Resources:
resources = Resources()

resources.add_postgres_snapshot_schedule(
"my_snapshot_schedule_2",
{
"branch": "projects/other-project/branches/production",
"schedule": [
{
"retention": "604800s",
"daily_schedule": {"hour": 5},
},
],
},
)

return resources
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

trace uv run $UV_ARGS -q $CLI bundle validate --output json | \
jq "pick(.experimental.python, .resources)"

rm -fr .databricks __pycache__
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Cloud = false # tests do not interact with APIs

# postgres_snapshot_schedules only exist in the current version of the wheel
EnvMatrix.PYDAB_VERSION = ["current"]

# postgres_snapshot_schedules are only supported on the direct deployment engine
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
18 changes: 18 additions & 0 deletions acceptance/bundle/refschema/out.fields.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3567,6 +3567,24 @@ resources.postgres_roles.*.status.postgres_role string REMOTE
resources.postgres_roles.*.status.role_id string REMOTE
resources.postgres_roles.*.update_time *time.Time REMOTE
resources.postgres_roles.*.url string INPUT
resources.postgres_snapshot_schedules.*.branch string ALL
resources.postgres_snapshot_schedules.*.id string INPUT
resources.postgres_snapshot_schedules.*.lifecycle resources.Lifecycle INPUT
resources.postgres_snapshot_schedules.*.lifecycle.prevent_destroy bool INPUT
resources.postgres_snapshot_schedules.*.modified_status string INPUT
resources.postgres_snapshot_schedules.*.name string REMOTE
resources.postgres_snapshot_schedules.*.schedule []postgres.ScheduleCadence ALL
resources.postgres_snapshot_schedules.*.schedule[*] postgres.ScheduleCadence ALL
resources.postgres_snapshot_schedules.*.schedule[*].daily_schedule *postgres.DailySchedule ALL
resources.postgres_snapshot_schedules.*.schedule[*].daily_schedule.hour int ALL
resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule *postgres.MonthlySchedule ALL
resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule.day int ALL
resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule.hour int ALL
resources.postgres_snapshot_schedules.*.schedule[*].retention duration.Duration ALL
resources.postgres_snapshot_schedules.*.schedule[*].weekly_schedule *postgres.WeeklySchedule ALL
resources.postgres_snapshot_schedules.*.schedule[*].weekly_schedule.day_of_week postgres.DayOfWeek ALL
resources.postgres_snapshot_schedules.*.schedule[*].weekly_schedule.hour int ALL
resources.postgres_snapshot_schedules.*.url string INPUT
resources.postgres_synced_tables.*.accelerated_sync bool ALL
resources.postgres_synced_tables.*.branch string ALL
resources.postgres_synced_tables.*.create_database_objects_if_missing bool ALL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
bundle:
name: deploy-pg-ss-basic-$UNIQUE_NAME

sync:
paths: []

resources:
postgres_projects:
my_project:
project_id: test-pg-proj-$UNIQUE_NAME
display_name: "Test Project for Snapshot Schedules"
pg_version: 16

postgres_snapshot_schedules:
main_schedule:
# Snapshots are only allowed on the project's root branch (the implicitly
# created "production" branch).
branch: ${resources.postgres_projects.my_project.id}/branches/production
schedule:
- daily_schedule:
hour: 3
retention: "604800s"
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule"
}
{
"method": "PATCH",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule",
"q": {
"update_mask": "schedule"
},
"body": {
"schedule": [
{
"daily_schedule": {
"hour": 3
},
"retention": "604800s"
}
]
}
}
{
"method": "POST",
"path": "/api/2.0/postgres/projects",
"q": {
"project_id": "test-pg-proj-[UNIQUE_NAME]"
},
"body": {
"spec": {
"display_name": "Test Project for Snapshot Schedules",
"pg_version": 16
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]"
}
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule"
}
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule"
}
{
"method": "PATCH",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule",
"q": {
"update_mask": "schedule"
},
"body": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]"
}
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]"
}
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule"
}
{
"method": "GET",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule"
}
{
"method": "PATCH",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule",
"q": {
"update_mask": "schedule"
},
"body": {
"schedule": [
{
"daily_schedule": {
"hour": 5
},
"retention": "604800s"
}
]
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading