ec-pg 0.1.7 → 0.1.8
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.
- checksums.yaml +4 -4
- data/lib/ec/pg/schema_manager.rb +10 -7
- data/lib/ec/pg/version.rb +1 -1
- data/lib/ec/pg.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 927ed76ae446cafa9cfa09623eb2ed3b05adf7973023c21de25353a95e7f59b2
|
|
4
|
+
data.tar.gz: 59865a939e8b813ec9872d4c27e9e5b7313dae76edf001cc175d79f41f76cb66
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e54504bc522de9c78e56344bae59e0b4661cc4fdce52ebc393ea210ab5c09d1fe1d49e8d7fc49b610f0c3ac729747ec82d028703d41ec9b7fb0650fee0337e9
|
|
7
|
+
data.tar.gz: 067f8f312bc09007fef2544b45a94f91f7c7e5196dc74101c736bef801875b3795b57f04ec156db2b647bb181acf159e7e6e25a77915d7a01e49786eb84b7978
|
data/lib/ec/pg/schema_manager.rb
CHANGED
|
@@ -81,9 +81,12 @@ module Ec
|
|
|
81
81
|
|
|
82
82
|
# Builds the search_path string and executes SET search_path on the connection.
|
|
83
83
|
def apply_schema(schema_name)
|
|
84
|
-
|
|
84
|
+
registered_models.each do |model|
|
|
85
|
+
connection = model.connection
|
|
85
86
|
shared = Ec::Pg.configuration.shared_schemas
|
|
86
87
|
path = ([schema_name] + shared).uniq.join(", ")
|
|
88
|
+
|
|
89
|
+
Ec::Pg.dprint("%s: Switching to schema: %s" % [model, path], color: :green)
|
|
87
90
|
connection.schema_search_path = path
|
|
88
91
|
end
|
|
89
92
|
end
|
|
@@ -94,8 +97,10 @@ module Ec
|
|
|
94
97
|
shared = Ec::Pg.configuration.shared_schemas
|
|
95
98
|
path = ([default] + shared).uniq.join(", ")
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
registered_models.each do |model|
|
|
101
|
+
connection = model.connection
|
|
98
102
|
if connection && connection.pool.present?
|
|
103
|
+
Ec::Pg.dprint("%s: Restoring schema to: %s" % [model, path], color: :red)
|
|
99
104
|
connection.schema_search_path = path
|
|
100
105
|
end
|
|
101
106
|
end
|
|
@@ -103,10 +108,8 @@ module Ec
|
|
|
103
108
|
# Swallow errors during cleanup (connection may have been returned to pool)
|
|
104
109
|
end
|
|
105
110
|
|
|
106
|
-
def
|
|
107
|
-
Ec::Pg::SchemaMixin
|
|
108
|
-
.registered_models
|
|
109
|
-
.map(&:connection)
|
|
111
|
+
def registered_models
|
|
112
|
+
Ec::Pg::SchemaMixin.registered_models
|
|
110
113
|
end
|
|
111
114
|
|
|
112
115
|
# Guards against SQL injection via schema names.
|
|
@@ -120,7 +123,7 @@ module Ec
|
|
|
120
123
|
"Only alphanumeric characters and underscores are allowed."
|
|
121
124
|
end
|
|
122
125
|
|
|
123
|
-
module_function :apply_schema, :restore_schema, :validate_schema_name!, :
|
|
126
|
+
module_function :apply_schema, :restore_schema, :validate_schema_name!, :registered_models
|
|
124
127
|
end
|
|
125
128
|
end
|
|
126
129
|
end
|
data/lib/ec/pg/version.rb
CHANGED
data/lib/ec/pg.rb
CHANGED