Skip to content

Instantly share code, notes, and snippets.

@bdthinh
Created April 18, 2015 12:14
Show Gist options
  • Save bdthinh/dcdb48d498b2219ecac1 to your computer and use it in GitHub Desktop.
Save bdthinh/dcdb48d498b2219ecac1 to your computer and use it in GitHub Desktop.
For psql with Rails 4
module ActiveRecord
module Tasks
class PostgreSQLDatabaseTasks
def drop
establish_master_connection
connection.select_all "select pg_terminate_backend(pg_stat_activity.pid) from pg_stat_activity where datname='#{configuration['database']}' AND state='idle';"
connection.drop_database configuration['database']
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment