Created
May 28, 2024 16:33
-
-
Save ryenski/559d651fae71a11e8b8e091ebc5b4892 to your computer and use it in GitHub Desktop.
Protect production environment from destructive rake tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Raise exception if used in production' | |
task protect_prod: [:environment] do | |
raise 'This task cannot be run in production' if Rails.env.production? | |
end | |
['db:drop', 'db:reset', 'db:seed'].each do |t| | |
Rake::Task[t].enhance ['protect_prod'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment