Should Doltgres have a CLI?

DOLTGRES
5 min read

It's Doltgres Beta week here at DoltHub. In eager anticipation of tomorrow's Doltgres Beta launch, I have an appetizer to get you interested in Doltgres again.

Currently, Doltgres does not ship with a Git- or Dolt-style command line interface (CLI). This simplifies the product and its interface, making it easier for new users to understand what Doltgres is. Doltgres is a version controlled database. It's Postgres with extra version control features. Use Doltgres the same way you would use Postgres.

But, this choice has a downside. The Dolt CLI is useful, especially for the data sharing use case. Doltgres users must use a Doltgres server and Postgres client.

Is the upside worth the downside? Should Doltgres have a Dolt-style CLI? This article explores these questions.

What is the Dolt CLI?

Dolt is modeled after Git and shares a similar style CLI. For those familiar with Git, you'll notice Dolt supports Git commands like checkout, branch, commit, and log with a few extras like sql-server, sql and query-diff.

$ dolt
Valid commands for dolt are
                init - Create an empty Dolt data repository.
              status - Show the working tree status.
                 add - Add table changes to the list of staged table changes.
                diff - Diff a table.
               reset - Remove table changes from the list of staged table changes.
               clean - Remove untracked tables from working set.
              commit - Record changes to the repository.
                 sql - Run a SQL query against tables in repository.
          sql-server - Start a MySQL-compatible server.
                 log - Show commit logs.
                show - Show information about a specific commit.
              branch - Create, list, edit, delete branches.
            checkout - Checkout a branch or overwrite a table from HEAD.
               merge - Merge a branch.
           conflicts - Commands for viewing and resolving merge conflicts.
         cherry-pick - Apply the changes introduced by an existing commit.
              revert - Undo the changes introduced in a commit.
               clone - Clone from a remote data repository.
               fetch - Update the database from a remote data repository.
                pull - Fetch from a dolt remote data repository and merge.
                push - Push to a dolt remote.
              config - Dolt configuration.
              remote - Manage set of tracked repositories.
              backup - Manage a set of server backups.
               login - Login to a dolt remote host.
               creds - Commands for managing credentials.
                  ls - List tables in the working set.
              schema - Commands for showing and importing table schemas.
               table - Commands for copying, renaming, deleting, and exporting tables.
                 tag - Create, list, delete tags.
               blame - Show what revision and author last modified each row of a table.
         constraints - Commands for handling constraints.
             migrate - Executes a database migration to use the latest Dolt data format.
         read-tables - Fetch table(s) at a specific commit into a new dolt repo
                  gc - Cleans up unreferenced data from the repository.
                fsck - Verifies the contents of the database are not corrupted.
       filter-branch - Edits the commit history using the provided query.
          merge-base - Find the common ancestor of two commits.
             version - Displays the version for the Dolt binary.
                dump - Export all tables in the working set into a file.
                docs - Commands for working with Dolt documents.
               stash - Stash the changes in a dirty working directory away.
             profile - Manage dolt profiles for CLI global options.
          query-diff - Shows table diff between two queries.
              reflog - Show history of named refs.
              rebase - Reapplies commits on top of another base tip
                  ci - Commands for working with Dolt continuous integration configuration.
               debug - Run a query in profile and trace mode

You can use Dolt in two modes:

  1. Git for Data mode which relies heavily on the CLI.
  2. Version Controlled Database mode which relies on a SQL Server and a SQL client.

Dolt also mostly works in a hybrid mode where you have a SQL Server running and run Dolt CLI commands in the root directory of the server. We've improved this mode a lot but there are some rough edges there that we continue to find and smooth over.

Why does Dolt have a CLI?

A better question might be "Why does Dolt have a SQL interface?" Dolt started as a CLI. There was no built in SQL Server. The idea was that Dolt was a data sharing tool. You would import tables on branches using dolt table import, review diffs, and share and merge Dolt repositories on DoltHub.

It was only after using the product ourselves for a few months that it became obvious that SQL was a necessary ingredient. Thus, we added SQL for table schema, a dolt sql CLI command, and a dolt sql-server command to start a MySQL-compatible server. Repositories became databases. We did this using the go-mysql-server open source project, which we have since adopted as the primary maintainers.

After over six years, most people use Dolt as a MySQL replacement in version controlled database mode. They start a Dolt server, interact with it via one of hundreds of supported MySQL clients, and kind of ignore the CLI. We can even run a server for you, AWS-style, using Hosted Dolt. With Hosted Dolt, users have no command line access so we need almost everything you can do via the CLI to be able to be done via SQL.

However, to this day, some operations can only be done via the CLI. filter-branch is a good example of a command you must run on the CLI. filter-branch is an esoteric and dangerous command, running SQL at every commit in your log, modifying history. We're saving the hardest commands for SQL migration for last.

Issues with the Dolt CLI

Why would we remove the Dolt CLI in Doltgres? There must be some issues right? Indeed.

Confusing for New Users

First and foremost, the fact that Dolt has multiple modes of operation confuses new users. What is Dolt for? Is it Git for data? Is it a version controlled database? Dolt is already new and innovative and the CLI mode confuses some users as to what Dolt is for. Most users use Dolt as a MySQL replacement. The CLI is mostly redundant for that use case.

Weird Interaction with a Running Server

As mentioned earlier, there are a few rough edges when using the CLI together with a running Dolt server. dolt table import does not work. Checking out a branch on the CLI when a server is running errors for reasons. dolt sql -q 'call dolt_checkout("branch")" is a no-op. We've made this work a lot better over the past couple years but things can get weird.

Technical Complexity

We generally err on the side of features for users > technical complexity. But, it's worth noting that Dolt would be simpler to build and maintain without a CLI.

Why doesn't Doltgres have a CLI?

In light of those issues, we chose to remove the Dolt CLI in Doltgres to make the product simpler. For new users, Doltgres is easier to to understand. Doltgres is a version controlled database. It's Postgres with extra version control features, exposed as SQL functions and system tables. Use Doltgres the same way you would use Postgres.

Simple. Right?

Should Doltgres have a CLI?

That said, we're still not sure if removing the Dolt CLI was the right choice given the trade offs. Are we going to stand firm against the first Doltgres user that wants us to add the CLI back? I don't know. Do you think Doltgres should have a CLI? Come by our Discord and argue with us.

SHARE

JOIN THE DATA EVOLUTION

Get started with Dolt

Or join our mailing list to get product updates.