I have something like the following defined
desc 'prompt are you sure'
task :are_you_sure do
unless ENV['FORCE'] == 'true'
puts ""
puts "THIS WILL BLOW AWAY THE DATABASE"
puts "hit enter to continue (control c to abort)"
puts ""
STDIN.read(1)
end
end
task :refresh => %w(are_you_sure db:pull db:convert db:test:prepare)
rake db:refresh prompts
rake db:refresh FORCE=true does not
Or if you wanted to require FORCE=true, you can do the following:
desc 'require force param'
task :require_force do
raise "This modifies production. To run, please specify FORCE=true" unless
ENV['FORCE'] == 'true'
end
--K
On Mar 25, 2010, at 11:12 AM, Mike Doel wrote:
> On Mar 25, 2010, at 10:55 AM, Sean Schofield wrote:
>
>> I'm loving the heroku db:pull stuff but its a bit dangerous if you
>> accidentally run db:push on a production system. Would it be possible
>> to have db:push warn you that the remote database is not empty? Maybe
>> something like the following:
>>
>> WARNING: Remote database is not empty. Are you sure you want to
>> replace its contents with the contents of your local database? If so
>> please use heroku db:push with the --force option.
>
> We tend to use rake tasks for pushing/pulling instead of using the heroku gem
> directly. Something like:
>
> namespace :db do
> task :refresh => ['db:pull','db:convert','db:test:prepare']
> task :pull => [:drop, :create] do
> system 'heroku db:pull'
> end
>
> # Include in here any rake tasks needed to seed or modify data for
> # current iteration
> task :convert => ['db:migrate']
> end
>
> That's for pulling instead of pushing (now that we're live, we never push -
> only migrate/convert).
>
> Once you get in the habit of doing 'rake db:refresh' instead of 'heroku
> db:pull', it becomes natural.
>
> You could build a rake task that wraps db:push and warns you before doing its
> thing.
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/heroku?hl=en.