LoginSignup
9
11

More than 5 years have passed since last update.

Rails のマイグレーションをフックする

Posted at

Rails のマイグレーションの前後に任意の処理をしたいとき、以下のように書きます。

desc 'Before task'
task :before do
  puts 'Before'
end

desc 'After task'
task :after do
  puts 'After'
end

Rake::Task['db:create'].enhance([:before]) do
  Rake::Task[:after].invoke
end
9
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
11