Databricks Databricks ★ 92 5 min

Lakebase and Agentic SDLC: Branching Databases for Coding Agents

PlatformAnnouncementsProduct

🔗 https://www.databricks.com/blog/lakebase-and-agentic-sdlc-branching-databases-coding-agents

📌 Lakebase資料庫分支:讓每個Coding Agent都有專屬資料庫

TL;DR:Databricks Lakebase用copy-on-write技術讓資料庫像Git一樣可以秒級分支,解決多個coding agent並行開發時的資料庫衝突問題。

當你同時開好幾個coding agent處理不同任務時,程式碼可以用Git worktree各自隔離,但資料庫呢?多數團隊仍共用一個開發或staging資料庫,這正是Databricks這篇文章點出的被忽視的痛點。

🤔 共用資料庫,agent們互相踩到對方

文章指出,隨著coding agent承擔越來越多開發工作,開發者傾向同時平行執行多個agent。每個agent都需要讀取資料庫schema、套用變更、填入測試資料、執行測試。在傳統共用環境下,agent之間會在schema變更上互相衝突、干擾彼此,或是退而求其次使用無法反映真實情況的mock資料。agent移動速度快、又平行運作,風險因此被放大:可能讓production資料暴露,或處理到敏感資訊。

🧩 像Git branch一樣分支整個資料庫

Lakebase Postgres架構的解法是資料庫分支(database branching)。就像Git讓你分支程式碼,Lakebase讓你在一秒內分支整個資料庫,且不受資料庫大小影響。它採用copy-on-write,分支會共享parent branch的資料,只有在資料產生分歧時才會額外消耗儲存空間;閒置的分支還能scale-to-zero,不佔用運算資源。

實際做法是搭配Git worktree:每個agent在自己的worktree目錄下工作,透過repository的post-checkout hook,自動為每個新worktree建立對應的資料庫分支。Agent的行為可以透過AGENTS.md或CLAUDE.md這類repository指令檔案來引導,例如完成開發後自動開PR。一旦PR建立,對應的worktree與資料庫分支就可以一起退役。

💡 分支不會合併回去,schema變更要靠migration工具

文章特別強調一個與Git不同之處:Lakebase分支不會合併回main branch。因為parent和child可能各自獨立變化,要協調兩邊的資料很快會變得不切實際。取而代之的作法是把schema變更寫進程式碼中,隨應用程式邏輯一起管理,再透過Drizzle、Flyway、Liquibase或Alembic等migration工具,將變更promote到parent branch(範例repository中使用的是Drizzle)。

在CI流程中,每個PR會從production分支出一個暫時的Lakebase分支,作為該PR的資料庫環境,自動測試與preview應用程式都可以對著這個分支跑。因為分支源自production,schema migration也能在真正推上production前先在這裡驗證過。PR合併後,程式碼與migration被promote,暫時分支就被刪除。

除了開發流程,文章也提到分支可以用在debug(從production某個時間點分支出來重現bug)與migration安全驗證(先在分支上套用migration並測試,驗證無誤後才promote到production)等場景,但這兩者並未在範例repository中實作。

⚠️ 目前以單一workspace示範,企業場景通常更複雜

文章提到常見的作法是每個環境(dev、staging、prod)各用一個Databricks workspace,主要是出於安全與合規考量;分支來源通常也是「已填入測試資料的seeded資料庫」而非直接用production,以避免暴露PII。文章為求簡化採用單一workspace示範,但強調核心概念同樣適用於多workspace設定。

🎯 實務啟示

如果你的團隊正在用coding agent並行開發,資料庫隔離和程式碼隔離(Git worktree)同樣重要。「每個agent一個分支、每個PR一個分支、production驗證用隔離分支」這三個模式,構成了一個可以直接套用的Lakebase開發迴圈,值得在導入多agent開發流程時一併考慮資料庫層的隔離策略。

🔗 來源

#Databricks #Lakebase #Postgres #CodingAgents #DatabaseBranching #DevOps #AgenticSDLC #CICD #GitWorktree #SchemaManagement

原始資料 Databricks · 收集於 2026-10-08
來源原標題
Lakebase and Agentic SDLC: Branching Databases for Coding Agents
機構
Databricks
原始標籤
Platform · Announcements · Product
原始連結
https://www.databricks.com/blog/lakebase-and-agentic-sdlc-branching-databases-coding-agents

摘要原文

AI has changed how software gets built. As coding agents take on a growing share of development work, developers are increasingly shifting toward orchestrating them. Running multiple agents in parallel is becoming the norm, and the tooling has evolved with it, from skills and hooks to MCPs, subagents, all designed to make agents safer and more effective. Yet, one mission-critical part in the development workflow is still often overlooked: the database. Each concurrent agent needs to write code, apply schema changes, and run tests against a database. With shared environments, such as a single development or staging database typical of traditional database setups, this creates real challenges. Agents can conflict on schema changes, interfere with one another's, or fall back to mocks that do not reflect real-world data. These were already pain points for developers, but they are exacerbated by coding agents. Agents move faster, operate in parallel and need a safe environment to avoid putting production data at risk or exposing sensitive data. The Lakebase Postgres architecture solves this with database branching. Just as Git lets you branch code, Lakebase lets you branch an entire database in under a second, regardless of its size. It uses copy-on-write, so branches share the parent branch data but only consume additional storage as they diverge. In addition, they can scale-to-zero, meaning idle branches incur no compute cost. This is important as you run several agents at the same time. Each branch is fully isolated, allowing an agent to apply migrations, run tests, and retire the branch when they’re done. In this article, I'll show you what this looks like in practice with an end-to-end workflow for a Lakebase development loop built around coding agents. An example repository is available here with examples of Github Actions workflows to achieve what is described in the following sections. Prefer to see it in action? Watch the video walkthrough below. Before we dive in, a note on environments with Databricks. A common setup when using Lakebase Postgres is to use one Databricks workspace per environment, such as dev, staging, and prod. Most teams will want to leverage workspaces for various reasons like security and compliance, although it is also possible to use a single workspace. Similarly, branching from a seeded database instead of the production database is also common, to avoid exposing sensitive data like PII. In this article, we’ll use a single workspace for simplicity, but the same core concepts apply to multi-workspace setups and can be implemented just as easily. The main disruption to traditional databases comes from multiple coding agents working concurrently. When developing new features or fixing issues, each agent often needs to read the database schema, apply changes, seed data, and run tests. Without isolation, these agents can interfere with one another or corrupt a shared database. Database branching gives each agent an isolated environment to work independently without affecting other agents running at the same time. A practical way to avoid code conflict locally is to leverage Git worktrees. A worktree gives each agent its own directory with its own branch checked out, so there's no file-level conflict between them. Git worktrees solve code isolation for parallel agents. Lakebase branching solves the other half: database isolation. By adding a post-checkout hook to the repository, each new worktree automatically gets its own database branch. Once the development is done, the agent will open a PR. Agent behavior can be guided through repository instruction files such as AGENTS.md or CLAUDE.md . Here is an example workflow using Claude Code, worktrees and Lakebase branching for safe AI development: When the agent is done, it will create PR. This behavior is provided in the repository instruction file . Once the PR is created, both the worktree and the database branch can be retired. One important difference from Git is that Lakebase branches are not merged back to the main branch. Because the parent and child can both change independently, reconciling their data can quickly become impractical. Instead, schema changes are tracked in code alongside the application logic, then promoted to the parent branch through migrations using tools such as Drizzle, Flyway, Liquibase, or Alembic. In our example, we use Drizzle. When a schema change is needed, the agent adds the corresponding migration to the codebase. The deployment automation then applies that migration when deploying the preview application and again when the change is merged into the main branch. Once a Pull Request (PR) is opened, we want to automatically validate and test the code against a real database before anything reaches production. Using continuous integration tooling, in this case, Github Actions, an ephemeral Lakebase branch is created for each PR, as a child of the production branch. That branch becomes the database environment for the PR. Automated tests can run against it, a preview application can be deployed, and reviewers can validate the change against a real database. Because the branch starts from production, the schema migration can also be applied and tested before the change reaches production. Once the PR is approved and merged, the feature code and migration instructions are promoted, and the temporary Lakebase branch is deleted. A common GitHub Actions workflow looks like this: In the repository example, we deploy the application with Databricks Apps , but the concept applies to any other hosting platforms like Vercel, Netlify, Cloudflare and more. Beyond development tasks, database branching can support several other useful workflows. These are not implemented in the example repository, but they can be valuable additions to a Lakebase development workflow. For example, with database branching, you can create an isolated branch from production at a point in time, typically right before a bug appeared, and investigate the issue against the real data, reproduce the bug safely, and retire the branch once the fix is validated. Branching can also make schema migrations safer. Before deploying a change to production, you can automatically create a database branch, apply the migration, run tests, and verify that the application still behaves as expected. Once the migration is validated, the same change can be promoted to production. These workflows are powerful because they let developers work with production-like, or production-derived data using Unity Catalog masking for example, without putting the live database at risk. Each branch is isolated, ephemeral, making it a safe environment for debugging, testing, and validation. Together, these patterns form the Lakebase development loop: a branch per agent, a branch per PR, and isolated branches for production validation. For the Agentic SDLC, database branching provides a safe and flexible foundation for development teams working with coding agents. Try branching out for yourself . Subscribe to our blog and get the latest posts delivered to your inbox.

由 claude-code/sonnet 自動生成