0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Ruby on Rails】マイグレーション時に、任意のrakeタスクを実行する

Last updated at Posted at 2022-09-30

今回は、マイグレーション時にrakeタスクを実行する実装をしたので、備忘録です。

実装

Rake::Task['db:migrate'].enhance do
  Rake::Task['任意のタスク'].invoke
end

やっていることとしては、enhanceでdb:migrateを事前タスクとして指定して、actionの中で任意のtaskをinvokeしているといった感じです。
独自のログを出力したり、最新のDBを自動でダンプしたりと使いどころは多いかと思います。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?