yam-db-charmer 1.7.4.13 → 1.7.4.14
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.
@@ -52,11 +52,17 @@ module DbCharmer
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
# Fake model that's used by exist_pg_database? to establish a db connection
|
56
|
+
class DatabaseDetectConnection < ::ActiveRecord::Base
|
57
|
+
end
|
58
|
+
|
59
|
+
# given the a db server config and a db name
|
60
|
+
# returns true if db_name exists
|
55
61
|
def exist_pg_database?(server_config, db_name)
|
56
62
|
config_no_db_name = server_config.clone
|
57
63
|
config_no_db_name['database'] = nil
|
58
|
-
establish_connection(config_no_db_name)
|
59
|
-
server_connection =
|
64
|
+
DatabaseDetectConnection.establish_connection(config_no_db_name)
|
65
|
+
server_connection = DatabaseDetectConnection.connection
|
60
66
|
sql = "SELECT datname FROM pg_database WHERE datname='#{db_name}'"
|
61
67
|
existing_dbs = server_connection.execute(sql)
|
62
68
|
server_connection.disconnect!
|
@@ -13,7 +13,7 @@ module ActiveRecord
|
|
13
13
|
|
14
14
|
def sharded_reflection?
|
15
15
|
# TODO: put this logic in WF
|
16
|
-
if klass.db_charmer_allocated_shard_connection && klass.db_charmer_extended
|
16
|
+
if klass.db_charmer_allocated_shard_connection && klass.respond_to?(:db_charmer_extended) && klass.db_charmer_extended
|
17
17
|
return true;
|
18
18
|
end
|
19
19
|
return false
|
data/lib/db_charmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yam-db-charmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 107
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
9
|
- 4
|
10
|
-
-
|
11
|
-
version: 1.7.4.
|
10
|
+
- 14
|
11
|
+
version: 1.7.4.14
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Oleksiy Kovyrin
|