Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added more debugging around restore.

  • Loading branch information...
commit ad47f3244fb8202e2d3bea5b8aefc9f98705dbba 1 parent 9f6f582
Wayne E. Seguin authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 lib/psql-cm/restore.rb
14 lib/psql-cm/restore.rb
View
@@ -19,7 +19,6 @@ def restore!
schema = cm_file.sub(".sql",'')
ensure_schema_exists(database,schema)
-
psqlrc_file = File.join(ENV['HOME'],'.psqlrc')
FileUtils.touch(psqlrc_file) unless File.exists?(psqlrc_file)
psqlrc = File.read(psqlrc_file)
@@ -27,8 +26,8 @@ def restore!
file.rewind
file.write "SET search_path TO #{schema}; "
end
- begin
+ begin
debug "restore> #{database}:#{schema} < #{cm_file}"
sh "psql #{db(database).psql_args} #{database} < #{cm_file}"
@@ -38,15 +37,18 @@ def restore!
WHERE is_base = $1 ORDER BY created_at ASC;"
Tempfile.open('base.sql') do |temp_file|
+ debug "restore:base:sql> #{sql.sub('$1','true')}"
row = db(database).exec(sql, ['true'])
temp_file.write(row)
sh "psql #{db(database).psql_args} #{database} < #{temp_file.path}"
end
- debug "sql> #{sql}"
- db(database).exec(sql,['false']).each do |row|
- debug "change>\n#{row['content']}"
- Tempfile.open('base.sql') do |temp_file|
+ debug "restore:changes:sql> #{sql.sub('$1','false')}"
+ changes = db(database).exec(sql,['false'])
+ debug "restore:change:count>#{changes.cmd_tuples}"
+ changes.each do |row|
+ debug "restore:change:content>\n#{row['content']}"
+ Tempfile.open('change.sql') do |temp_file|
temp_file.write(row['content'])
temp_file.close
sh "psql #{db(database).psql_args} #{database} < #{temp_file.path}"
Please sign in to comment.
Something went wrong with that request. Please try again.