Merge branch '21383-misc-fixes'. Refs #21383
[arvados.git] / services / api / Rakefile
index 925e6c2d1dc11d58c4f662be5c032db022719a68..70ceb653e6f72afc79de5be38c5005486c1d2324 100644 (file)
@@ -1,14 +1,13 @@
 #!/usr/bin/env rake
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 # Add your own tasks in files placed in lib/tasks ending in .rake,
 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
 
 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
+require 'rake/testtask'
 
 Server::Application.load_tasks
 
@@ -39,12 +38,28 @@ namespace :db do
       require 'tempfile'
       origfnm = File.expand_path('../db/structure.sql', __FILE__)
       tmpfnm = Tempfile.new 'structure.sql', File.expand_path('..', origfnm)
+      copyright_done = false
+      started = false
       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.
+          if !copyright_done
+            if !/Copyright .* Arvados/.match(line)
+               tmpfile.write "-- Copyright (C) The Arvados Authors. All rights reserved.\n--\n-- SPDX-License-Identifier: AGPL-3.0\n\n"
+            end
+            copyright_done = true
+          end
+
+          if !started && /^[^-\n]/ !~ line
+            # Ignore the "PostgreSQL database dump" comment block,
+            # which varies from one client version to the next.
+            next
+          end
+          started = true
+
+          if /^SET (lock_timeout|idle_in_transaction_session_timeout|row_security) = / =~ line
+            # Avoid edit wars between versions that do/don't write (and can/can't execute) this line.
             next
           elsif /^COMMENT ON EXTENSION/ =~ line
             # Avoid warning message when loading: