Created
April 18, 2015 12:14
-
-
Save bdthinh/dcdb48d498b2219ecac1 to your computer and use it in GitHub Desktop.
For psql with Rails 4
This file contains 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
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