Skip to content

Instantly share code, notes, and snippets.

@searls
Created February 1, 2023 19:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save searls/5c6b77213dbc7202ca39f4e70d975eee to your computer and use it in GitHub Desktop.
Save searls/5c6b77213dbc7202ca39f4e70d975eee to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Useful when you want to git bisect in a rails app and know
# you need to `bin/rake db:migrate VERSION="SOMETHING"` before
# you check out the next commit so the database is in the right
# state, but you don't know what SOMETHING is.
# Usage:
#
# $ migration_version_at_ref <REF>
ref="$1"
git ls-tree --name-only "$ref:db/migrate" | tail -n 1 | cut -f 1 -d '_'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment