psql-cm 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.2.1 - 2012-05-22
2
+
3
+ Added more debug output.
4
+ Explicitely exclude pg\_psql\_cm from setup dump.
5
+
1
6
  # 0.2.0 - 2012-05-17
2
7
 
3
8
  Ownership and privileges are now recorded.
data/lib/psql-cm/base.rb CHANGED
@@ -76,7 +76,8 @@ module PSQLCM
76
76
 
77
77
  def sh(command)
78
78
  debug "$ #{command}"
79
- %x[#{command} 2>&1 | awk '! /NOTICE/']
79
+ output = %x[#{command} 2>&1 | awk '! /NOTICE/']
80
+ debug output
80
81
  end
81
82
 
82
83
  def uri
@@ -22,10 +22,10 @@ module PSQLCM
22
22
  psqlrc_file = File.join(ENV['HOME'],'.psqlrc')
23
23
  FileUtils.touch(psqlrc_file) unless File.exists?(psqlrc_file)
24
24
  psqlrc = File.read(psqlrc_file)
25
- File.open(psqlrc_file,'w') do |file|
26
- file.rewind
27
- file.write "SET search_path TO #{schema}; "
28
- end
25
+
26
+ file = File.open(psqlrc_file,'w')
27
+ file.write "SET search_path TO #{schema}; "
28
+ file.close
29
29
 
30
30
  begin
31
31
  tag = "restore:#{database}:#{schema}>"
@@ -39,10 +39,10 @@ module PSQLCM
39
39
  debug tag, "base:sql> #{sql}"
40
40
  db(database).exec(sql).each do |base_row|
41
41
  debug "BASE content:", base_row['content']
42
- Tempfile.open('base.sql') do |file|
43
- file.write(base_row['content'])
44
- sh "psql #{db(database).psql_args} #{database} < #{file.path}"
45
- end
42
+ tempfile = Tempfile.open('base.sql')
43
+ tempfile.write(base_row['content'])
44
+ sh "psql #{db(database).psql_args} #{database} < #{tempfile.path}"
45
+ tempfile.close
46
46
  end
47
47
 
48
48
  sql = "SELECT content from #{schema}.#{config.cm_table}
@@ -54,17 +54,15 @@ module PSQLCM
54
54
  debug tag, "change:count>#{changes.cmd_tuples}"
55
55
  changes.each do |row|
56
56
  debug tag, "content>\n#{row['content']}"
57
- Tempfile.open('change.sql') do |file|
58
- file.write(row['content'])
59
- file.close
60
- sh "psql #{db(database).psql_args} #{database} < #{file.path}"
61
- end
57
+ tempfile = Tempfile.open('change.sql')
58
+ tempfile.write(row['content'])
59
+ sh "psql #{db(database).psql_args} #{database} < #{tempfile.path}"
60
+ tempfile.close
62
61
  end
63
62
  ensure
64
- File.open(psqlrc_file,'w') do |file|
65
- file.rewind
66
- file.write psqlrc
67
- end
63
+ file = File.open(psqlrc_file,'w')
64
+ file.write psqlrc
65
+ file.close
68
66
  end
69
67
  end
70
68
  end
data/lib/psql-cm/setup.rb CHANGED
@@ -9,7 +9,7 @@ module PSQLCM
9
9
 
10
10
  Tempfile.open('base.sql') do |temp_file|
11
11
  sh %W[ pg_dump #{db(database).psql_args}
12
- --schema-only --no-owner --no-privileges
12
+ --schema-only --no-owner --no-privileges --exclude-table=pg_psql_cm
13
13
  --schema=#{schema} --file=#{temp_file.path} #{database}
14
14
  ].join(' ')
15
15
 
@@ -1,4 +1,4 @@
1
1
  module PSQLCM
2
- Version = '0.2.0'
2
+ Version = '0.2.1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psql-cm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-17 00:00:00.000000000 Z
12
+ date: 2012-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg