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
namespace :db do | |
namespace :drop do | |
task connections: :environment do | |
begin | |
database = ActiveRecord::Base.connection.current_database | |
ActiveRecord::Base.connection.execute(<<-SQL) | |
SELECT pg_terminate_backend(pg_stat_activity.pid) | |
FROM pg_stat_activity | |
WHERE pg_stat_activity.datname = '#{database}' AND pid <> pg_backend_pid(); | |
SQL |
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
Moved to: http://github.com/gf3/dotfiles/blob/master/bash_prompt |