storey 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bb3f2b4defb8e7efc5b8fc40436f55af4f108e84a036acd96a88719b0ce609b
4
- data.tar.gz: b7c0a0382f6b0569f310e89da8408623a334260773bfbb21ae22bae2c98cfc88
3
+ metadata.gz: 89dc451e50d3e25bfa3e2f4028f1718059cd28f8aafab7aaf87a1815837f9121
4
+ data.tar.gz: 3f32de0842a1c7d05b91fc7b715fbb1710d8452e0fe7db00eb740994d35cb80e
5
5
  SHA512:
6
- metadata.gz: 8f5cd71b0a6b1792e58dd0b2e47af04eb679b1cba49336f7e1a7f8c961568cc18d8fa810e553da368466e9786e1e6ec2d45af66f7613e08558a2427e463f45aa
7
- data.tar.gz: 85c6de9f6818ec7fa46d6326a91c9c105a82e04e40e0ede0ba6744a78b60b61ced509ce041ec2f068d10c88df385f8b84553e1e6234397297ccce3b78d4592b1
6
+ metadata.gz: 73992092bc15f428a45bea3b4a9de2794f9eeb72f0aaec6d3eee7b36b2cf6c4030ae10d6b9f869702589acc724b3c92dabb4597373541926be2e01fe05b5ba7c
7
+ data.tar.gz: 0617b1dd0a58fe4bf1d8dacfcd8a1cddd8efcf8ef5ff7f384edbbffd950a905525529f3de1e005a133d647a2806d365be3b5a12c07855f9f81a1c9c234f3e9d3
@@ -2,6 +2,11 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [2.0.2] - 2018-06-29
6
+ ### Fixed
7
+ - Fix instances when the default schema is the wrong schema
8
+ - Silence output when creating schemas
9
+
5
10
  ## [2.0.1] - 2018-06-27
6
11
  ### Fixed
7
12
  - Do not blow up `rake db:create` in Rails 5.2
data/README.md CHANGED
@@ -39,16 +39,16 @@ Usage:
39
39
 
40
40
  ## schemas
41
41
 
42
- Returns all schemas except postgres' schemas.
42
+ Returns all postgres' schemas.
43
43
 
44
44
  Accepts options:
45
45
 
46
- :exclude_public => true
46
+ :public => true
47
47
 
48
48
  Usage:
49
49
 
50
- Storey.schemas
51
- Storey.schemas(:exclude_public => true)
50
+ Storey.schemas # defaults to :public => true
51
+ Storey.schemas(:public => true)
52
52
 
53
53
  ## default_schema?
54
54
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- storey (2.0.0)
4
+ storey (2.0.1)
5
5
  easy_class_to_instance_method (~> 0.0.2)
6
6
  pg
7
7
  rails (>= 4.0.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- storey (2.0.0)
4
+ storey (2.0.1)
5
5
  easy_class_to_instance_method (~> 0.0.2)
6
6
  pg
7
7
  rails (>= 4.0.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- storey (2.0.0)
4
+ storey (2.0.1)
5
5
  easy_class_to_instance_method (~> 0.0.2)
6
6
  pg
7
7
  rails (>= 4.0.0)
@@ -37,7 +37,7 @@ module Storey
37
37
  end
38
38
 
39
39
  def default_search_path
40
- @@default_search_path ||= self.schema
40
+ set_default_search_path
41
41
  default_search_paths = @@default_search_path.split(',')
42
42
  paths = default_search_paths + self.persistent_schemas
43
43
  paths.uniq!
@@ -93,7 +93,7 @@ module Storey
93
93
  def create_plain_schema(schema_name)
94
94
  name = suffixify schema_name
95
95
  command = "CREATE SCHEMA #{name}"
96
- system psql_load_command(command: command)
96
+ Open3.capture3 psql_load_command(command: command)
97
97
  end
98
98
 
99
99
  def schemas(options={})
@@ -124,6 +124,8 @@ module Storey
124
124
  end
125
125
 
126
126
  def switch(name=nil, &block)
127
+ set_default_search_path
128
+
127
129
  if block_given?
128
130
  original_schema = schema
129
131
  switch name
@@ -243,4 +245,8 @@ module Storey
243
245
  BuildsLoadCommand.execute(self.database_config.merge(options))
244
246
  end
245
247
 
248
+ def set_default_search_path
249
+ @@default_search_path ||= self.schema
250
+ end
251
+
246
252
  end
@@ -53,9 +53,14 @@ module Storey
53
53
  arg_options['schema-only'] = nil if @structure_only
54
54
 
55
55
  switches = Utils.command_line_switches_from(arg_options)
56
-
57
- success = system("pg_dump #{switches} #{Storey.database_config[:database]}")
58
- unless success
56
+ pg_dump_command = [
57
+ "pg_dump",
58
+ switches,
59
+ Storey.database_config[:database],
60
+ ].join(" ")
61
+
62
+ stdout_str, stderr_str, status = Open3.capture3(pg_dump_command)
63
+ unless status.exitstatus.zero?
59
64
  raise StoreyError, "There seems to have been a problem dumping `#{@source_schema}` to make a copy of it into `#{@target_schema}`"
60
65
  end
61
66
  end
@@ -78,7 +83,7 @@ module Storey
78
83
  end
79
84
 
80
85
  psql_load_command = BuildsLoadCommand.execute(psql_options)
81
- system psql_load_command
86
+ Open3.capture3(psql_load_command)
82
87
 
83
88
  copy_source_schema_migrations
84
89
 
@@ -1,3 +1,3 @@
1
1
  module Storey
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -4,6 +4,14 @@ describe 'Storey', '#default_search_path' do
4
4
 
5
5
  context "when #default_search_path has not been set before" do
6
6
  it "defaults to the current schema" do
7
+ Storey.create "anotherschema"
8
+
9
+ # A bit of a hack, but set the @@default_search_path so we can test
10
+ # the scenario when no path has been set
11
+ Storey.class_variable_set("@@default_search_path", nil)
12
+
13
+ Storey.switch "anotherschema"
14
+
7
15
  expect(Storey.default_search_path).to eq '"$user",public'
8
16
  end
9
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storey
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2018-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails