Skip to content

Migrations

Schemas evolve. Bowerbird provides tools to migrate your notes when your schema changes, keeping your vault consistent without manual edits.

When you modify your schema, existing notes may become inconsistent:

  • Rename a field — Old notes still use the old name
  • Remove a select option — Notes may reference invalid values
  • Rename a type — Notes live in the wrong directory
  • Remove a field — Old notes have orphaned data

Migrations update existing notes to match the new schema.

Bowerbird’s migration system follows four principles:

  1. Migrations are explicit — You intentionally trigger migrations; they don’t run automatically
  2. Safe by default — Dry-run mode shows what would change before applying
  3. Backup by default — A backup is created before changes are applied
  4. Git handles history — Bowerbird tracks current and last-applied states; use Git for deeper history

The typical workflow has four steps:

Edit .bwrb/schema.json to make your changes (add fields, rename types, etc.).

Run bwrb schema diff to see pending changes:

Terminal window
bwrb schema diff
Pending Schema Changes
Deterministic changes (will be auto-applied):
+ Add field "importance" to type "idea"
+ Add field "source" to type "idea"
Non-deterministic changes (require confirmation):
- Remove field "priority" from type "idea"
Note: Schema version is still 1.0.0.
You'll be prompted to update it when running `bwrb schema migrate --execute`.
Run `bwrb schema migrate` to preview the migration.
Run `bwrb schema migrate --execute` to apply changes.

Run bwrb schema migrate (without --execute) to see what would happen:

Terminal window
bwrb schema migrate
Migration Preview (Dry-Run)
Deterministic changes (will be auto-applied):
+ Add field "importance" to type "idea"
+ Add field "source" to type "idea"
Non-deterministic changes (require confirmation):
- Remove field "priority" from type "idea"
Files scanned: 4
Files affected: 0
Run `bwrb schema migrate --execute` to apply these changes.

When ready, execute the migration:

Terminal window
bwrb schema migrate --execute

This will:

  1. Prompt for a new schema version
  2. Create a backup (unless --no-backup is passed)
  3. Apply changes to affected notes
  4. Save the new schema snapshot
  5. Record the migration in history

Bowerbird classifies schema changes into two categories:

These can be applied automatically without user input:

ChangeNotes Don’t Need Updates Because…
Add fieldMissing fields are valid (fields aren’t required by default)
Add select optionExisting values remain valid
Add typeNo existing notes to update

These require confirmation because they affect existing data:

ChangeWhat Happens
Remove fieldField is removed from affected notes
Rename fieldField name is updated in affected notes
Remove select optionAffected notes flagged for review
Rename typeNotes are moved to the new directory
Remove typeExisting notes become orphaned (warning)

When you run bwrb schema migrate --execute, Bowerbird suggests a version bump based on your changes:

Change SeverityVersion BumpExample
Breaking (removals, renames)Major1.0.0 → 2.0.0
AdditionsMinor1.0.0 → 1.1.0
No structural changesPatch1.0.0 → 1.0.1

You can accept the suggestion or enter your own version.

Bowerbird stores migration state in .bwrb/:

.bwrb/
├── schema.json # Current schema (you edit this)
├── schema.applied.json # Last successfully migrated schema
├── migrations.json # History of applied migrations
└── backups/ # Timestamped backups before migrations
  • schema.json: Your current schema definition
  • schema.applied.json: Snapshot from the last migration — used to compute diffs
  • migrations.json: Log of all migrations with timestamps and changes
  • backups/: Timestamped directories containing pre-migration file copies

See past migrations with:

Terminal window
bwrb schema history
bwrb schema history --limit 5

Bowerbird does not have a rollback command. Instead:

  1. Use Git — Commit your schema and notes together. Roll back with git checkout or git revert
  2. Use backups — Migrations create backups in .bwrb/backups/
  3. Fix forward — Make additional schema changes and run another migration

This design keeps Bowerbird focused on schema management while Git handles version control.

When you first use migrations on a vault:

Terminal window
bwrb schema diff
No previous schema snapshot found.
This is either a new vault or migrations haven't been used yet.
Run `bwrb schema migrate --execute` to create the initial snapshot.

Run the initial migration to establish a baseline:

Terminal window
bwrb schema migrate --execute
Initial schema snapshot created (version 1.0.0)
Future schema changes will be tracked from this point.

Keep schema.json and affected notes in the same commit:

Terminal window
# Make schema changes, then:
bwrb schema migrate --execute
git add .bwrb/ Notes/
git commit -m "Rename priority to importance"

Never run --execute without previewing:

Terminal window
bwrb schema diff # What changed in the schema?
bwrb schema migrate # What will happen to notes?
bwrb schema migrate --execute # Apply when ready

Your schema version communicates intent:

  • Major (2.0.0): Breaking changes that affect how notes are used
  • Minor (1.1.0): New capabilities, backward compatible
  • Patch (1.0.1): Fixes or clarifications

Don’t rely on .bwrb/migrations.json for rollback. It’s for reference, not recovery. Keep your vault in Git.

CommandPurpose
bwrb schema diffShow pending schema changes
bwrb schema migratePreview or apply migrations
bwrb schema historyView migration history