Skip to content

Commit 98f9a99

Browse files
committed
Fix migration handling in subdirs
1 parent e6a8012 commit 98f9a99

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bin/git_rails

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ if [ ! -z "$migrations" ]; then
137137
fi
138138

139139
# BUILD THE MIGRATION COMMAND FROM THE VERSION AND TYPE
140-
version=`echo "$migration" | cut -d'_' -f1 | cut -d'/' -f3`
140+
version=`echo "$migration" | grep -o 'db/migrate/.*' | cut -d'_' -f1 | cut -d'/' -f3`
141141
migrate_command="ActiveRecord::Migrator.run(:$migration_type, 'db/migrate', $version) rescue nil"
142142

143143
# APPEND OR PREPREND TO THE COMMAND LIST DEPENDING ON MIGRATION TYPE
144144
if [[ $migration_type == "down" ]]; then
145145
# CHECKOUT DOWN MIGRATION AND SAVE PATH FOR CLEANUP
146-
git checkout "$old_ref" -- "$migration"
147-
migration_cleanup="$migration_cleanup $migration"
146+
git checkout "$old_ref" -- ":/$migration"
147+
migration_cleanup="$migration_cleanup $(git ls-files :/$migration)"
148148
migrate_commands="$migrate_command;$migrate_commands"
149149
else
150150
migrate_commands="$migrate_commands;$migrate_command"

0 commit comments

Comments
 (0)