ardb 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ardb/adapter/postgresql.rb +11 -3
- data/lib/ardb/version.rb +1 -1
- data/test/unit/adapter/postgresql_tests.rb +2 -2
- metadata +3 -3
@@ -7,8 +7,8 @@ class Ardb::Adapter
|
|
7
7
|
|
8
8
|
def public_schema_settings
|
9
9
|
self.config_settings.merge({
|
10
|
-
|
11
|
-
|
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.
|
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
@@ -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
|
-
|
18
|
-
|
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