# US 2023/0267103 A1 · Database Schema Branching Workflow, with Support for Data, Keyspaces and VSchemas

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0267103 A1
- Document ID: US20230267103A1
- Status: Published application
- Kind: A1
- Application number: 18/138,001
- Filed: 2023-04-21
- Published: 2023-08-24
- Earliest claimed: 2021-03-29
- Assignees: PlanetScale, Inc.
- Applicants: PlanetScale, Inc.
- Inventors: Sam George Lambert; Patrick A. Reynolds; Shlomo Noach; Nicholas Diego Van Wiggeren; Jordan Tyler Williams
- Web page: https://patentgrep.com/patent/US20230267103A1

## CPC

- G06F 16/213: {with details for schema evolution support}
- G06F 16/219: {Managing data history or versioning (querying versioned data G06F16/2474; querying temporal data G06F16/2477)}
- G06F 16/211: {Schema design and management}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A branch of a main database is created, comprising a copy of the main database schema. A user edits the branch and requests that it be merged back into the main database. A schema diff is generated and used to determine differences between the main database and the edited branch. The merge is performed if it does not create a conflict. A second branch is created and edited by a second user. When the second user indicates to merge the second branch back into the main database, differences between the two branches are determined, relative to the main database. If merging the second branch back into the main database on top of the first branch does not create a conflict, a three-way merge is performed of the first branch, the second branch, and the version of the main database from which the first and second branches were generated.

## Claims

### Claim 1

A computer implemented method for maintaining version control for databases in a database version tracking system, with branching support for database schemas, the method comprising:
creating a first branch of a main database from the database version tracking system;
wherein the first branch further comprises a copy of the main database in a specific state, as recorded in the database version tracking system, the copy being created in a workspace isolated from the database version tracking system, the copy comprising at least a copy of a schema of the main database in a specific state;
responsive to receiving a control signal from a user associated with the first branch indicating to merge a changed version of the first branch back into the database version tracking system, determining differences between a current version of the main database as tracked by the database version tracking system and the changed version of the first branch;
wherein determining differences between the current version of the database and the changed version of the first branch further comprises generating at least one schema diff;
determining, from the at least one schema diff, whether merging the changed version of the first branch back into the database version tracking system creates a conflict; and
responsive to determining that merging the changed version of the first branch back into the database version tracking system does not create a conflict, merging the changed version of the first branch back into the database version tracking system;
wherein merging the changed version of the first branch back into the database version tracking system further comprises performing at least one schema operation from a group of schema operations consisting of: create table, drop table and alter table, the at least one schema operation being indicated by the at least one schema diff.

### Claim 2 (depends on 1)

The method of claim 1 further comprising:
creating a second branch of the main database from the database version tracking system;
wherein the second branch further comprises a copy of the main database separate from the copy comprising the first branch, the separate copy being created in a workspace isolated from the database version tracking system, the copy comprising at least a copy of the schema of the main database in the specific state;
responsive to receiving a control signal from a user associated with the second branch indicating to merge a changed version of the second branch back into the database version tracking system, determining differences between the changed version of the first branch and the changed version of the second branch, relative to a version of the main database as tracked by the database version tracking system from which the first branch and the second branch were generated;
wherein determining differences further comprises generating at least one schema diff;
determining, from the at least one schema diff, whether merging the changed version of the second branch back into the database version tracking system on top of the changed first version of the first branch creates a conflict; and
responsive to results of the determining, performing a step from a group of steps consisting of:
responsive to determining that merging the changed version of the second branch back into the database version tracking system on top of the changed version of the first branch does not create a conflict, merging the changed version of the second branch back into the database version tracking system on top of the changed version of the first branch, the merging further comprising performing at least one schema operation from a group of schema operations consisting of: create table, drop table and alter table; and
responsive to determining that merging the changed version of the second branch back into the database version tracking system on top of the changed version of the first branch does create a conflict, not merging the changed version of the second branch back into the database version tracking system on top of the changed version of the first branch.

### Claim 3 (depends on 2)

The method of claim 2 further comprising:
responsive to determining that merging the changed version of the second branch back into the database version tracking system on top of the changed version of the first branch does create a conflict, outputting information concerning the conflict to the user associated with the second branch.

### Claim 4 (depends on 2)

The method of claim 2 further comprising:
responsive to determining that merging the changed version of the second branch back into the database version tracking system on top of the changed version of the first branch does create a conflict, outputting suggestions concerning at least one schema change to resolve the conflict, to the user associated with the second branch.

### Claim 5 (depends on 2)

The method of claim 2 wherein merging the changed version of the second branch back into the database version tracking system on top of the changed version of the first branch further comprises:
performing a three-way merge of the changed version of the first branch, the changed version of the second branch, and the version of the main database as tracked by the database version tracking system from which the first branch and the second branch were generated, utilizing the at least one schema diff.

### Claim 6 (depends on 2)

The method of claim 2 further comprising:
maintaining a queue of pending changes that are in the process of being merged back into the main database as tracked by the database version tracking system.

### Claim 7 (depends on 6)

The method of claim 6 further comprising:
combining, reordering and/or canceling at least one of the pending changes.

### Claim 8 (depends on 1)

The method of claim 1 further comprising:
utilizing a reconciliation process to perform at least one step from a group of steps consisting of:
creating a database branch;
destroying a database branch;
taking a snapshot of at least one schema; and
applying at least one schema to an existing database.

### Claim 9 (depends on 8)

The method of claim 8 wherein utilizing a reconciliation process further comprises:
determining a desired end-state;
calculating steps to reach the end-state from a current state; and
executing the calculated steps.

### Claim 10 (depends on 8)

The method of claim 8 wherein utilizing a reconciliation process further comprises:
determining a desired end-state;
calculating steps to reach the end-state from a current state;
executing a subset of the calculated steps;
responsive to a failure or interruption prior to executing all of the calculated steps, calculating an updated, set of steps to achieve the desired end-state from an updated current state; and
executing the updated calculated steps.

### Claim 11 (depends on 10)

The method of claim 10 wherein the updated set of steps is shorter.

### Claim 12 (depends on 1)

The method of claim 1 wherein determining differences between the current version of the database and the changed version of first branch further comprises:
identifying changes the user associated with the first branch made to the copy of the schema of the main database.

### Claim 13 (depends on 2)

The method of claim 2 wherein creating a branch further comprises:
creating a copy of the main database in the specific state by creating a copy of the schema of the main database, and copying data from the main database into the copy of the main database.

### Claim 14 (depends on 13)

The method of claim 13 wherein copying data from the main database into the copy of the main database further comprises:
copying a subset of the data stored in the main database.

### Claim 15 (depends on 13)

The method of claim 13 wherein copying data from the main database into the copy of the main database further comprises:
copying a filtered subset of the data stored in the main database, further comprising filtering the data stored in the main database according to at least one criterion from a group of criteria consisting of: data sensitivity, data content, storage location and sharding architecture.

### Claim 16 (depends on 13)

The method of claim 13 wherein copying data from the main database into the copy of the main database further comprises:
copying all of the data stored in the main database.

### Claim 17 (depends on 2)

The method of claim 2 wherein creating a branch further comprises:
creating a copy of the main database in the specific state by creating a copy of the schema of the main database, and populating the copy of the main database with programmatically created data or with a stored data set.

### Claim 18 (depends on 13)

The method of claim 13 wherein merging a branch further comprises:
restoring changed branch data back into the main database.

### Claim 19 (depends on 13)

The method of claim 13 wherein creating a branch further comprises:
creating a copy of at least one object-relational mapping system migration control table of the main database.

### Claim 20 (depends on 19)

The method of claim 19 wherein merging a branch further comprises:
merging at least one change to the copy of the at least one object-relational mapping system migration control table into the at least one object-relational mapping system migration control table of the main database.
