scatterd-dotfiles/aliases
Geoff Harcourt 8597a61f61 Run db:test:prepare task on migrate alias
We removed `db:test:prepare` from the `migrate` alias in #260 because
Rails 4.1 discouraged users from running the deprecated (at the time)
Rake task. Rails brought back `db:test:load` in rails/rails#17739 due to
user complaints about being unable to force a test database
synchronization.

Without dropping and recreating the test database from scratch, the
current migration strategy of solely using `db:migrate` and
`db:rollback` will never bring changes into test from a migration that
was run, rolled back, modified, and then re-run.

Running `db:test:load` or `db:test:prepare` on each migrate operation
has a small performance penalty, but the task is only being run when you
have a reason to want to check or force a synchronization of the
database. Knowing for sure that your test and development databases are
at the same point in their evolution is worthwhile.

Running `db:test:prepare` or `db:test:load` after running our existing
migrate alias added just under 1.0 seconds on average to the migrate
operation on an application with a reasonably sized DB schema.

diff --git a/aliases b/aliases index 6a0f602..102caca 100644 ---
a/aliases +++ b/aliases @@ -9,7 +9,7 @@ alias v="$VISUAL" alias
b="bundle"

 # Rails
-alias migrate="rake db:migrate db:rollback && rake db:migrate"
+alias migrate="rake db:migrate db:rollback && rake db:migrate db:test:prepare"
 alias s="rspec"

 # Pretty print the path
2015-11-29 08:38:30 -05:00

19 lines
378 B
Text

# Unix
alias ll="ls -al"
alias ln="ln -v"
alias mkdir="mkdir -p"
alias e="$EDITOR"
alias v="$VISUAL"
# Bundler
alias b="bundle"
# Rails
alias migrate="rake db:migrate db:rollback && rake db:migrate db:test:prepare"
alias s="rspec"
# Pretty print the path
alias path='echo $PATH | tr -s ":" "\n"'
# Include custom aliases
[[ -f ~/.aliases.local ]] && source ~/.aliases.local