X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c59093180fd92f0d7c6607a49458446212ebd058..f81f84e19902e37c28fd1610999cfefa1c4a0b71:/services/api/Rakefile diff --git a/services/api/Rakefile b/services/api/Rakefile index 22b25313a5..fbbf53e3c6 100644 --- a/services/api/Rakefile +++ b/services/api/Rakefile @@ -32,3 +32,34 @@ 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