Skip to content

Add tern migrate command with up/down subcommands#66

Merged
RobbieMcKinstry merged 2 commits into
trunkfrom
claude/add-migrate-command-RAPRI
Jan 24, 2026
Merged

Add tern migrate command with up/down subcommands#66
RobbieMcKinstry merged 2 commits into
trunkfrom
claude/add-migrate-command-RAPRI

Conversation

@RobbieMcKinstry

Copy link
Copy Markdown
Contributor

FEATURE: Add tern migrate up/down commands with tern up/down as aliases

Implements the migrate command with two subcommands:

  • migrate up: Run pending migrations (same as existing up)
  • migrate down: Revert the most recently applied migration

The down command computes inverse operations for reversible migrations
and removes the migration record from the database tracking tables.
Irreversible operations (like DropTable) will error with a clear message.

tern up and tern down are now aliases for tern migrate up/down
for convenience.

FEATURE: Add tern migrate up/down commands with tern up/down as aliases

Implements the migrate command with two subcommands:
- migrate up: Run pending migrations (same as existing up)
- migrate down: Revert the most recently applied migration

The down command computes inverse operations for reversible migrations
and removes the migration record from the database tracking tables.
Irreversible operations (like DropTable) will error with a clear message.

tern up and tern down are now aliases for tern migrate up/down
for convenience.
FEATURE: Store inverse operations in migration files for offline reversal

This changes down migrations from being computed on-the-fly at runtime
to being computed and persisted when migrations are generated. Key changes:

- Rename Migration.operations to up_operations
- Add Migration.down_operations field for pre-computed inverse operations
- Add src/db/migrate/inverse.rs module for computing inverse operations
- Update all migration generation paths (generate, import, init) to
  compute and store down_operations
- Simplify down command to use pre-computed operations
- Add is_reversible() method to Migration

Breaking change: Migration JSON format now uses up_operations/down_operations
instead of operations field.
@RobbieMcKinstry RobbieMcKinstry merged commit f05d06a into trunk Jan 24, 2026
6 checks passed
@RobbieMcKinstry RobbieMcKinstry deleted the claude/add-migrate-command-RAPRI branch January 24, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants