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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 157ee10e3c8c4d9e57fd9440bf4b923334b000dda03b154134846dff1193fa59
4
- data.tar.gz: 5323bfb06b17e7afdca65474408f6a351cbc99c6e4d7dc27410cb8ce8ae648b6
3
+ metadata.gz: f517a947adebfd5ef21779eacad13021c7cab081ed0836c5d995a435f545b3e8
4
+ data.tar.gz: 3cb062ee05bbc8fcc110a1adf2f7a23361d150b88e0c398fe675283b54b21e09
5
5
  SHA512:
6
- metadata.gz: 0c599a3ca9b9f069a08e56a89db93b14c4b5d767ba69490bd0c4495c1542bace4471170941540b6bcb8a0e5f5277f26a0510d85a062220cc124855ad1e6a24b2
7
- data.tar.gz: e73f5eb43e4433ef1e5f998e5358c322dc947d3f5313572affd4e7b6f5dd62c63a92bddc8c5a2bb1d5538fa799d86f2dbfa44de02a8a222406dce9fb11509f6d
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
- $ bundle install
13
+ ```bash
14
+ $ bundle install
15
+ ```
14
16
 
15
- Or install it yourself as:
17
+ ## Usage
16
18
 
17
- $ gem install schema-utils
19
+ Inicializar a lib:
18
20
 
19
- ## Usage
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
 
@@ -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.schema_search_path
7
+ default_search_path = conn.execute("SHOW search_path").first["search_path"]
8
8
 
9
- # Set the schema that you want run the migration
10
- conn.schema_search_path = schema
11
- yield schema
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.schema_search_path = default_search_path
18
+ conn.execute("SET search_path TO #{default_search_path}")
15
19
  end
16
20
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SchemaUtils
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
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.1
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-05 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord