schema_utils 0.0.1 → 0.0.2
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/README.md +20 -4
- data/lib/migrate.rb +9 -5
- data/lib/schema_utils.rb +14 -0
- data/lib/schema_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f517a947adebfd5ef21779eacad13021c7cab081ed0836c5d995a435f545b3e8
|
4
|
+
data.tar.gz: 3cb062ee05bbc8fcc110a1adf2f7a23361d150b88e0c398fe675283b54b21e09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f4e97285e4a78056cb91560ed57495d516a302b00ea8e6e0ce8adf7f70997bee59304082cf9bd856a4207ae574e72dd9c6550b81b34ec4a039225a8911cc7a5
|
7
|
+
data.tar.gz: bb6ce24ad9beb4ae21decefcab9832d87d15c3ac4bb7cedd39ad2d33f82a56bbca73d7fd91b78df0cbb47670dd45fc7b2648c363d00e1f75425d24d2d971e985
|
data/README.md
CHANGED
@@ -10,13 +10,29 @@ gem 'schema_utils'
|
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
13
|
-
|
13
|
+
```bash
|
14
|
+
$ bundle install
|
15
|
+
```
|
14
16
|
|
15
|
-
|
17
|
+
## Usage
|
16
18
|
|
17
|
-
|
19
|
+
Inicializar a lib:
|
18
20
|
|
19
|
-
|
21
|
+
```ruby
|
22
|
+
# ../config/initializers/schema_utils.rb
|
23
|
+
|
24
|
+
require "schema_utils"
|
25
|
+
#
|
26
|
+
# SchemaUtils Configuration
|
27
|
+
#
|
28
|
+
SchemaUtils.configure do |config|
|
29
|
+
# There are cases where you might want some schemas to always be in your search_path
|
30
|
+
# e.g when using a PostgreSQL extension like pgcrypto.
|
31
|
+
# Any schemas added here will be available along with your selected Schema.
|
32
|
+
#
|
33
|
+
config.persistent_schemas = %w[shared_extensions]
|
34
|
+
end
|
35
|
+
```
|
20
36
|
|
21
37
|
Dentro da migration incluir:
|
22
38
|
|
data/lib/migrate.rb
CHANGED
@@ -4,13 +4,17 @@ class Migrate
|
|
4
4
|
def self.on_schema(schema)
|
5
5
|
conn = ActiveRecord::Base.connection
|
6
6
|
|
7
|
-
default_search_path = conn.
|
7
|
+
default_search_path = conn.execute("SHOW search_path").first["search_path"]
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
schema_search_path = [schema, SchemaUtils.persistent_schemas].flatten.map(&:inspect).join(", ")
|
10
|
+
|
11
|
+
# Set the custom schema
|
12
|
+
conn.execute("SET search_path TO #{schema_search_path}")
|
13
|
+
|
14
|
+
# Execute migration block
|
15
|
+
yield
|
12
16
|
|
13
17
|
# Return to default schema path
|
14
|
-
conn.
|
18
|
+
conn.execute("SET search_path TO #{default_search_path}")
|
15
19
|
end
|
16
20
|
end
|
data/lib/schema_utils.rb
CHANGED
@@ -2,3 +2,17 @@
|
|
2
2
|
|
3
3
|
require "schema_utils/version"
|
4
4
|
require "migrate"
|
5
|
+
|
6
|
+
module SchemaUtils
|
7
|
+
class << self
|
8
|
+
attr_writer :persistent_schemas
|
9
|
+
|
10
|
+
def configure
|
11
|
+
yield self if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
def persistent_schemas
|
15
|
+
@persistent_schemas || []
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/schema_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Pontes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|