Skip to content

Commit 3201473

Browse files
committed
Make down migrations run faster
1 parent 02da705 commit 3201473

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bin/git_rails

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ if [ ! -z "$migrations_removed" ]; then
3030
fi
3131
git checkout "$old_ref" -- "$migration"
3232
version=`echo "$migration" | cut -d'_' -f1 | cut -d'/' -f3`
33-
bundle exec rake db:migrate:down VERSION="$version"
34-
git reset
35-
rm "$migration"
33+
migrate_commands="$migrate_commandsActiveRecord::Migrator.run(:down, 'db/migrate', $version) rescue nil"
3634
done
35+
echo "$migrate_commands" | bundle exec rails c
3736
bundle exec rake db:test:prepare
3837
git checkout $new_ref -- db/schema.rb
38+
git reset HEAD -- db/migrate
39+
git clean -df db/migrate
3940
fi
4041

4142
if [ ! -z "$migrations_added" ]; then

0 commit comments

Comments
 (0)