title: Run rake db:drop without failure if database doesn't exist
body: <p><a href="https://stackoverflow.com/questions/7129452/how-to-know-if-db-exists-from-within-rake-task#comment8545989_7129452">This comment</a> says:</p>
  
  <blockquote>
    <p>db:drop can run without failure when db does not exist</p>
  </blockquote>
  
  <p>This is exactly what I need: I need to run db:drop but without throwing an exception or halt my whole process if the database doesn't exist, just delete the database if it exists or do  nothing.</p>
  
  <p>How can I do that? how can I tell <code>db:drop</code> not to destroy my life if the database doesn't exist?</p>
  
  <p>This is the code I'm experiencing the problem with (it it help):</p>
  
  <pre><code>namespace :db do
    task import: :environment do
      Rake::Task["db:drop"].invoke # If the database doesn't already exist, the whole import process terminates!
      Rake::Task["db:create"].invoke
      Rake::Task["db:migrate"].invoke
      database_config = Rails.configuration.database_configuration[Rails.env]
      system "psql --username=#{database_config['username']} #{database_config['database']} &lt; PostgreSQL.sql"
    end
  end
  </code></pre>