Skip to content

Repository

Eric Hanson edited this page May 17, 2025 · 1 revision

This page describes the internal data structures of a repository and its commits, stage and row tracking. See here for design discussion.

Data Structures

1. delta.repository Table - contains all repositories.

Columns

  • name text - Repository name
  • head_commit_id uuid - The id of the commit that is currently being developed against. Next commit will use this commit as its parent, and all track, stage and diff functions compare the live db against the contents of this commit.
  • checkout_commit_id uuid - The commit that is currently checked out into the database, maintained by the delta.checkout() function.
  • tracked_rows_added jsonb - Array of row_id::text values
  • stage_rows_to_add jsonb - Array of row_id::text values? See Stage-by-Reference vs. Value
  • stage_rows_to_remove jsonb - Array of row_id::text values
  • stage_fields_to_change jsonb - Array of field_id::text values

stage_rows_added

Rows that have been staged for inclusion in the next commit, along with their value at stage time.

JSONB Object with key row_id::text and value of jsonb object with key column name and value of field value at stage time.

{
    "(shakespeare,character,{id},{Aaron})": {
        "id": "Aaron",
        "name": "Aaron",
        "abbrev": "AARON",
        "description": "a Moor, beloved by Tamora",
        "speech_count": 57
    },
    "(shakespeare,character,{id},{Bagot})": {
        "id": "Bagot",
        "name": "Bagot",
        "abbrev": "BAGOT",
        "description": "servant to King Richard II",
        "speech_count": 6
    }
}

stage_rows_deleted

JSONB Array of row_id::text values - rows that have been staged for deletion from the previous commit, to be excluded in the next commit

[
    "(shakespeare,character,{id},{Aaron})",
    "(shakespeare,character,{id},{Bagot})"
]

stage_fields_changed

JSONB Object, with key field_id::text and value of field's value at stage time.

{
    "(shakespeare,character,{id},{Aaron},name)": "Sally",
    "(shakespeare,character,{id},{Bagot},name)": "Joe"
}

2. delta.commit Table

Columns

  • parent_id uuid - foreign key to the previous commit, or NULL for first commit.
  • merge_parent_id uuid - If this commit is a merge, references the second commit that is being merged with the parent_id commit.
  • jsonb_rows - Array of row_ids, the contents of this commit, sorted in checkout order.
  • jsonb_fields - Object of fields in the commit.
    • Object keys are row_id::text
    • Object values are a sub-Object:
      • Object keys are column names
      • Object values are field values, potentially hashed according to hash rules
  • author_name text
  • author_email text
  • message text
  • commit_time text

Clone this wiki locally