/** * BranchService * * Manages database branching by creating/deleting PostgreSQL databases * using `CREATE DATABASE ... TEMPLATE`. Branch metadata is stored in the * `rebase.branches` table in the default (main) database, following the * same `rebase` schema convention used by entity_history, auth, etc. */ import { BranchInfo } from "@rebasepro/types"; import { DrizzleClient } from "../interfaces"; import { DatabasePoolManager } from "../databasePoolManager"; export declare class BranchService { private db; private poolManager; constructor(db: DrizzleClient, poolManager: DatabasePoolManager); /** * Ensure the `rebase.branches` metadata table exists in the default database. * Idempotent — safe to call on every startup. */ ensureBranchMetadataTable(): Promise; /** * Create a new branch database by templating the source database. * * Uses `CREATE DATABASE ... TEMPLATE` for an instant, full-fidelity copy * of both schema and data. * * @param name User-facing branch name (e.g., "feature_auth") * @param options.source Source database to clone; defaults to the main database. */ createBranch(name: string, options?: { source?: string; }): Promise; /** * Delete a branch database and remove its metadata. * Cannot delete the main/default database. */ deleteBranch(name: string): Promise; /** * List all branches recorded in the metadata table. * Optionally fetches database sizes from pg_database. */ listBranches(): Promise; /** * Get info about a specific branch. */ getBranchInfo(name: string): Promise; }