Skip to content

bakyazi/migshift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

migshift

migshift is a simple interactive CLI tool that helps you rename numbered SQL migration files by shifting their numbers up or down. This is particularly useful when you need to insert new migrations between existing ones or reorder your database migration files.

Features

  • Interactive file selection using arrow keys or vim-style navigation (j/k)
  • Multiple file selection support
  • Pagination for large file lists
  • Preserves original number formatting (leading zeros)
  • Works with any SQL migration files that follow the pattern: number_description.sql

Installation

go install github.com/bakyazi/migshift@latest

Usage

  1. Navigate to the directory containing your SQL migration files

  2. Run the tool:

    migshift
  3. Use the following controls to select files:

    • / or j/k: Move cursor
    • Space: Select/deselect file
    • Ctrl+j: Jump to first file
    • Ctrl+k: Jump to last file
    • Enter: Confirm selection
    • q: Quit
  4. After selecting files, enter a shift number:

    • Positive number: Shift file numbers up
    • Negative number: Shift file numbers down

Examples

Let's say you have these migration files:

001_create_users.sql
002_add_email.sql
003_add_timestamps.sql

If you want to insert a new migration between 001 and 002, you can:

  1. Select 002_add_email.sql and 003_add_timestamps.sql
  2. Enter shift number: 1

Result:

001_create_users.sql
002_add_email.sql -> 003_add_email.sql
003_add_timestamps.sql -> 004_add_timestamps.sql

Now you can create your new migration as 002_new_migration.sql

About

migshift

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages