Skip to content

Instantly share code, notes, and snippets.

View erichnascimento's full-sized avatar
🚧
Building the next big thing

Erich Nascimento erichnascimento

🚧
Building the next big thing
View GitHub Profile
@erichnascimento
erichnascimento / db.1.rake
Created November 19, 2017 21:34 — forked from maxd/db.1.rake
Rake task for drop active connections to PostgreSQL database
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
Moved to: http://github.com/gf3/dotfiles/blob/master/bash_prompt