X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d14dd75b263d8f999603b66d23f74667d36a2412..607fe087f6167061714a524dd53cbbc21b974973:/services/api/Rakefile diff --git a/services/api/Rakefile b/services/api/Rakefile index 22b25313a5..67e4202ba2 100644 --- a/services/api/Rakefile +++ b/services/api/Rakefile @@ -4,12 +4,6 @@ require File.expand_path('../config/application', __FILE__) -begin - ok = PgPower -rescue - abort "Hm, pg_power is missing. Make sure you use 'bundle exec rake ...'" -end - Server::Application.load_tasks namespace :test do @@ -32,3 +26,44 @@ namespace :test do end end end + +namespace :db do + namespace :structure do + task :dump do + require 'tempfile' + origfnm = File.expand_path('../db/structure.sql', __FILE__) + tmpfnm = Tempfile.new 'structure.sql', File.expand_path('..', origfnm) + begin + tmpfile = File.new tmpfnm, 'w' + origfile = File.new origfnm + origfile.each_line do |line| + if /^SET lock_timeout = 0;/ =~ line + # Avoid edit wars between versions that do/don't write this line. + next + elsif /^COMMENT ON EXTENSION/ =~ line + # Avoid warning message when loading: + # "structure.sql:22: ERROR: must be owner of extension plpgsql" + tmpfile.write "-- " + end + tmpfile.write line + end + origfile.close + tmpfile.close + File.rename tmpfnm, origfnm + tmpfnm = false + ensure + File.unlink tmpfnm if tmpfnm + end + end + end +end + +# Work around Rails3+PostgreSQL9.5 incompatibility (pg_dump used to +# accept -i as a no-op, but now it's not accepted at all). +module Kernel + alias_method :orig_backtick, :` + def `(*args) #`#` sorry, parsers + args[0].sub!(/\Apg_dump -i /, 'pg_dump ') rescue nil + orig_backtick(*args) + end +end