Migrating from v0.4.x to v0.5.0

v0.5.0 moves the storage of gest from flat TOML and Markdown files in a .gest/ directory to a single SQLite database, which gest opens through the libsql library. If you have a v0.4.x project, the gest migrate command imports all of it into the new database in one run.

This guide covers these topics:

Before you migrate

  1. Find your v0.4.x data. In v0.4.x, a local-mode project stored its data in .gest/ at the project root. A global-mode project stored its data under $XDG_DATA_HOME/gest/<sha256(cwd)[..8]>/, where the name of the directory is the first 8 characters of a SHA-256 hash of the path of the project. gest migrate finds either layout by itself, but you need to know which one you have to back it up.

    While you are still on v0.4.x, ask v0.4 for the project directory:

    gest config get storage.project_dir

    Only the v0.4.x binary has this key, and v0.5.0 removed it. So run the command before you upgrade.

  2. Back it up. Copy your old project directory to a safe place. Use the path from the step before:

    cp -r "$(gest config get storage.project_dir)" ~/gest-v0.4-backup

    Or, if you already know the layout:

    # For local-mode v0.4 projects
    cp -r .gest ~/gest-v0.4-backup
    
    # For global-mode v0.4 projects (example hash; run `ls ~/.local/share/gest/`
    # to find yours)
    cp -r ~/.local/share/gest/<old-hash> ~/gest-v0.4-backup
  3. Upgrade gest. Install v0.5.0:

    gest self-update

    gest --version now reports 0.5.0 or higher.

  4. Run the migration. From the root of your project, run:

    gest migrate --from v0.4

    You do not need to run gest init first. If the current working directory has no project yet, gest migrate creates one as part of the import.

Run the migration

gest migrate --from v0.4 does these steps:

  1. It looks for your old .gest/ directory in the current directory, then in each parent directory. Last, it checks the global location that v0.4.x used, $XDG_DATA_HOME/gest/<sha256(cwd)[..8]>/.

  2. It uses the v0.5.0 project of the current working directory, or it creates a new project for that directory.

  3. It reads every .toml file under tasks/ and tasks/resolved/, and adds each one as a task. Each task gets a new ID.

  4. It reads every .md file under artifacts/ and artifacts/archive/, and adds each one as an artifact with a new ID. Each file under artifacts/archive/ becomes an archived artifact. The type field of the old file becomes a tag.

  5. It reads every .toml file under iterations/ and iterations/resolved/, and adds each one as an iteration with a new ID. It adds the tasks of each iteration through their new IDs, all in phase 1.

  6. It adds the tags of every record.

  7. It adds the notes of each task and iteration. An author record is created for each name that wrote a note or that a task is assigned to.

  8. Last, it adds the links of each task and iteration as relationships. It maps the old ID of each target to its new ID, so a link can name any task, artifact or iteration in the import. A link whose target is not in the import is skipped with a warning. v0.4.x wrote each link on both records, so the migrator keeps one relationship for each pair, as gest task link makes. Between two iterations it keeps both, as gest iteration link makes. An artifact in the task list of an iteration becomes a relates-to link from the iteration.

  9. It prints a summary line:

    migrated 42 tasks, 17 artifacts, 5 iterations, 23 notes, 61 relationships

Explicit source path

The search may not find your data, for example when you moved the directory, or when you import from another checkout. Then pass --path:

gest migrate --from v0.4 --path /some/backup/.gest

Skipped files

When the migrator cannot parse a file, it logs a warning and counts the file as skipped. Then you see a summary line like this one:

skipped 3 files (the warnings above say why)

The warnings name each file that failed and the reason, and they print at the default log level. To see more detail, run gest -vv migrate --from v0.4. Common causes are files that someone edited by hand away from the v0.4.x format, and partial writes from an interrupted v0.4.x command.

How data maps from v0.4 to v0.5

v0.4.x location v0.5.0 destination
tasks/<id>.toml tasks table (status preserved)
tasks/resolved/<id>.toml tasks table (status done / cancelled)
artifacts/<id>.md artifacts table + sync mirror file
artifacts/archive/<id>.md artifacts table with archived_at set
iterations/<id>.toml iterations table (status active)
iterations/resolved/<id>.toml iterations table (status active)
Task assigned_to: "alice" authors row + tasks.assigned_to FK
Task and iteration notes notes table
Task events Not imported
Task and iteration links relationships table
Task/Iteration metadata (TOML table) JSON column on the row
Artifact metadata (YAML frontmatter) JSON column on the row
Artifact type: "spec" spec tag on the artifact
Artifact tags: [a, b, c] tags + entity_tags rows

The migration does not keep the IDs of v0.4.x. Each task, artifact and iteration gets a new ID, so an old ID in a commit message, a pull request or a note no longer finds its record. Inside the import, gest maps the old IDs to the new ones, for the tasks of each iteration and for every link. The migration also leaves resolved iterations active. Complete or cancel them again with gest iteration complete or gest iteration cancel.

After the migration

  1. Check the counts. Compare the summary of the migration with what you expect:

    gest task list --all --json | jq 'length'
    gest artifact list --all --json | jq 'length'
    gest iteration list --all --json | jq 'length'

    Each count must match the number of files in tasks/, artifacts/ and iterations/ of your old .gest/ directory, or exceed it if the database already had records.

  2. Check a few records. Pick a task, an artifact and an iteration that you know well. Look at each one with gest <entity> show <id>, and check its title, description, tags, links and notes. Find the records by title, because their IDs are new.

  3. Search your project. Run a search that you know:

    gest search "is:task tag:spec"

    If you used type: filters before, change your scripts and your shell history to use tag:.

  4. Turn on .gest/ sync (optional). If you used gest init --local on v0.4.x and want the sync to keep working, check that storage.sync is still true, which is the default. Then run any command. On its first export, the sync layer writes the .gest/ files from the new database.

  5. Remove old overrides of subdirectories. If your old gest.toml has any of these keys, delete them, because gest no longer reads them:

    [storage]
    project_dir  = "..."   # remove
    state_dir    = "..."   # remove
    artifact_dir = "..."   # remove
    task_dir     = "..."   # remove
    iteration_dir = "..."  # remove
  6. Remove the old .gest/ directory, but only when you are happy with the result. The migrator does not delete the source. It leaves everything in place, so that you can compare and check. When you are sure that the migration is correct, run:

    rm -rf .gest                                 # for local-mode v0.4 data
    rm -rf ~/.local/share/gest/<old-hash>        # for global-mode v0.4 data

    In a local-mode project, .gest/ can also hold the new database, .gest/gest.db. Check where your database is with gest config show before you delete the directory. Do this step only after you have checked that the database has everything.

What changes for you

v0.5.0 looks different in these ways:

  • gest.db is the source of truth. The data lives in SQLite, in <data_dir>/gest.db, or in .gest/gest.db for a project with a .gest/ directory. For a local-mode project, the files in .gest/ become a copy that gest rewrites from the database.
  • The type of an artifact is gone. Tags give the category now. The migrator turns each type: "spec" into a spec tag.
  • The type: filter of the search is gone. Use tag:spec, or another tag, instead.
  • artifact create takes the title as its first argument. The --title and --type flags no longer exist. -t now means --tag.
  • Several environment variables are gone. v0.5.0 removed or renamed GEST_PROJECT_DIR, GEST_STATE_DIR, GEST_ARTIFACT_DIR, GEST_TASK_DIR, GEST_ITERATION_DIR and GEST_LOG_LEVEL (with a single underscore). The Configuration reference gives the new names.
  • The undo history lives in the database. There is no separate directory for state any more. Undo works on the database that the command ran against.

See the v0.5.0 changelog entry for the full list.

Why v0.5.0 moved to SQLite

The main reason was the coordination of worktrees, not the speed of storage.

In v0.4.x, both modes of storage took the current working directory as the identity of the project:

  • Local mode wrote to .gest/ inside the worktree. So two worktrees of the same repository had two separate stores, and an agent in feature-a/ could not see the tasks that someone created in main/.
  • Global mode named the store by sha256(cwd)[..8], a hash of the working directory. So each worktree had a different hash and a different project, although they were the same project. Global mode had the same problem as local mode.

In neither mode could parallel agents share a live view of the tasks, artifacts and iterations of one project. Parallel agents are the main purpose of gest.

v0.5.0 makes the identity of a project explicit. A project is a row in a single global database, and each extra checkout joins it as a workspace. From a second worktree:

cd ../myapp-feature-a
gest project              # in the original checkout, copy the project id
gest project attach <project-id>

After the attach, both checkouts find the same project row and share the same tasks, artifacts and iterations. gest no longer hashes the working directory, so two worktrees of one repository no longer end up in separate projects.

When the identity of a project no longer came from the file system, SQLite was the natural store. It gives atomic writes across records, so a task, its tags and its relationships are saved together or not at all. It gives real queries for dependency graphs and for filters by tag. It also gives safe access for several agents that use the same store at the same time. The flat files could not give these three things. The three were benefits of the change, and not its reason.

For a local-mode project, a sync layer still copies the database to YAML and Markdown files in .gest/. Each kind of record has its own directory, with a singular name, such as task/, artifact/ and iteration/. So you can still read the data and commit it to git. The database is still the source of truth.

Discussion #28 has the original RFC, and ADR-0013 records the decision.

Rolling back

If the migration gave results that you did not expect, you can go back:

  1. Keep the v0.4.x .gest/ directory. The migrator never changes the source. If you did not do the cleanup step above, your old data is intact.
  2. Install v0.4.x again. cargo install gest --version 0.4.4 installs the last v0.4 release.
  3. Delete the v0.5.0 database. Remove <data_dir>/gest.db, or .gest/gest.db in a local-mode project. On Linux, <data_dir>/gest.db is usually ~/.local/share/gest/gest.db. Run gest config show to check. The v0.4.x binary does not know about SQLite storage, so it ignores the file. Its removal keeps your data directory clean.
  4. Restore your backup. Copy ~/gest-v0.4-backup from step 2 of the list before the migration back to its original location.

Please also open an issue that says what went wrong. The migrator is new, and the maintainers can fix the edge cases of v0.4.x files more easily when they see them.

See also

  • gest migrate, the CLI reference of the command
  • Configuration, the new config sections and environment variables
  • ADR-0013, the decision to move to SQLite-first storage