ardb 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,8 @@ class Ardb::Adapter
7
7
 
8
8
  def public_schema_settings
9
9
  self.config_settings.merge({
10
- :database => 'postgres',
11
- :schema_search_path => 'public'
10
+ 'database' => 'postgres',
11
+ 'schema_search_path' => 'public'
12
12
  })
13
13
  end
14
14
 
@@ -20,7 +20,15 @@ class Ardb::Adapter
20
20
 
21
21
  def drop_db
22
22
  ActiveRecord::Base.establish_connection(self.public_schema_settings)
23
- ActiveRecord::Base.connection.drop_database(self.database)
23
+ ActiveRecord::Base.connection.tap do |conn|
24
+ conn.execute "UPDATE pg_catalog.pg_database"\
25
+ " SET datallowconn=false WHERE datname='#{self.database}'"
26
+ # this SELECT actually runs a command: it terminates all the connections
27
+ # http://www.postgresql.org/docs/9.2/static/functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE
28
+ conn.execute "SELECT pg_terminate_backend(pid)"\
29
+ " FROM pg_stat_activity WHERE datname='#{self.database}'"
30
+ conn.execute "DROP DATABASE IF EXISTS #{self.database}"
31
+ end
24
32
  end
25
33
 
26
34
  def drop_tables
data/lib/ardb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ardb
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -14,8 +14,8 @@ class Ardb::Adapter::Postgresql
14
14
 
15
15
  should "know it's public schema connection settings" do
16
16
  exp_settings = subject.config_settings.merge({
17
- :database => 'postgres',
18
- :schema_search_path => 'public'
17
+ 'database' => 'postgres',
18
+ 'schema_search_path' => 'public'
19
19
  })
20
20
  assert_equal exp_settings, subject.public_schema_settings
21
21
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ardb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding