Branching Guide

One of ChronDB's most powerful features is its branching capability, inherited from its Git foundation. This guide will teach you how to use branches effectively in your applications.

What Are Branches?

In ChronDB, branches are isolated environments that contain their own version of the database. Changes in one branch don't affect others until you explicitly merge them. This enables:

  • Developing new features without affecting production data

  • Testing changes in isolation

  • Creating "what-if" scenarios

  • Supporting multiple concurrent users with different views

  • Providing tenant isolation in multi-tenant applications

Branching Use Cases

Let's explore practical applications of branching:

1. Development Workflows

Create isolated environments for development → testing → production:

main (production)

  test

   dev

2. Feature Branches

Develop and test each feature in isolation:

3. Tenant Isolation

Give each tenant their own branch for complete isolation:

4. Scenario Analysis

Create "what-if" scenarios for business analysis:

Getting Started with Branching

Let's walk through some practical examples:

Setup

Ensure you have ChronDB running:

Exercise 1: Creating a Development Branch

Let's create a real-world development workflow with branches:

Using the Clojure API

Using the REST API

Exercise 2: Testing with Branches

Let's simulate a testing workflow:

Exercise 3: Merging Branches

After testing, let's merge our changes to the main branch:

Using Clojure API

Using REST API

Exercise 4: Working with Multiple Users

Branching can isolate changes between different users:

Exercise 5: "What-If" Analysis for Business Scenarios

Advanced Branching Patterns

Multi-Tenant Architecture

In a multi-tenant SaaS application:

Feature Flagging with Branches

Test new features in isolation before enabling for all users:

Best Practices for Branching

  1. Keep a Clean Main Branch

    • Main should always contain stable, production-ready data

    • Only merge thoroughly tested changes

  2. Use Descriptive Branch Names

    • feature-new-ui, bugfix-pricing, tenant-acme

    • Include tracking numbers: feature-123-new-login

  3. Regular Merges

    • Regularly merge from main into development branches to prevent divergence

    • The longer branches exist separately, the harder merging becomes

  4. Delete Stale Branches

    • Remove branches after merging to keep your branch list clean

    • Consider archiving important historical branches

  5. Automate Branch Management

    • Use CI/CD pipelines to automate testing and merging

    • Integrate with your development workflow

Conclusion

Branching in ChronDB offers powerful capabilities for development workflows, testing, and multi-tenant applications. By understanding how to create, modify, and merge branches, you can leverage ChronDB's full potential to create isolated environments while maintaining the ability to consolidate changes when needed.

Next Steps

Community Resources

Last updated