Permalink
Browse files

Added more debug output.

Explicitely exclude pg_psql_cm from setup dump.
  • Loading branch information...
1 parent 400db0c commit c32f210f2c9a3bf23b3272837a7a4908f76f1272 @wayneeseguin committed May 22, 2012
Showing with 18 additions and 19 deletions.
  1. +2 −1 lib/psql-cm/base.rb
  2. +15 −17 lib/psql-cm/restore.rb
  3. +1 −1 lib/psql-cm/setup.rb
View
@@ -76,7 +76,8 @@ def run!(action = config.action)
def sh(command)
debug "$ #{command}"
- %x[#{command} 2>&1 | awk '! /NOTICE/']
+ output = %x[#{command} 2>&1 | awk '! /NOTICE/']
+ debug output
end
def uri
@@ -22,10 +22,10 @@ def restore!
psqlrc_file = File.join(ENV['HOME'],'.psqlrc')
FileUtils.touch(psqlrc_file) unless File.exists?(psqlrc_file)
psqlrc = File.read(psqlrc_file)
- File.open(psqlrc_file,'w') do |file|
- file.rewind
- file.write "SET search_path TO #{schema}; "
- end
+
+ file = File.open(psqlrc_file,'w')
+ file.write "SET search_path TO #{schema}; "
+ file.close
begin
tag = "restore:#{database}:#{schema}>"
@@ -39,10 +39,10 @@ def restore!
debug tag, "base:sql> #{sql}"
db(database).exec(sql).each do |base_row|
debug "BASE content:", base_row['content']
- Tempfile.open('base.sql') do |file|
- file.write(base_row['content'])
- sh "psql #{db(database).psql_args} #{database} < #{file.path}"
- end
+ tempfile = Tempfile.open('base.sql')
+ tempfile.write(base_row['content'])
+ sh "psql #{db(database).psql_args} #{database} < #{tempfile.path}"
+ tempfile.close
end
sql = "SELECT content from #{schema}.#{config.cm_table}
@@ -54,17 +54,15 @@ def restore!
debug tag, "change:count>#{changes.cmd_tuples}"
changes.each do |row|
debug tag, "content>\n#{row['content']}"
- Tempfile.open('change.sql') do |file|
- file.write(row['content'])
- file.close
- sh "psql #{db(database).psql_args} #{database} < #{file.path}"
- end
+ tempfile = Tempfile.open('change.sql')
+ tempfile.write(row['content'])
+ sh "psql #{db(database).psql_args} #{database} < #{tempfile.path}"
+ tempfile.close
end
ensure
- File.open(psqlrc_file,'w') do |file|
- file.rewind
- file.write psqlrc
- end
+ file = File.open(psqlrc_file,'w')
+ file.write psqlrc
+ file.close
end
end
end
@@ -9,7 +9,7 @@ def setup!
Tempfile.open('base.sql') do |temp_file|
sh %W[ pg_dump #{db(database).psql_args}
- --schema-only --no-owner --no-privileges
+ --schema-only --no-owner --no-privileges --exclude-table=pg_psql_cm
--schema=#{schema} --file=#{temp_file.path} #{database}
].join(' ')

0 comments on commit c32f210

Please sign in to comment.