5677: Edit structure.sql after db:structure:dump: avoid warnings when loading, and...
authorTom Clegg <tom@curoverse.com>
Fri, 26 Jun 2015 06:54:31 +0000 (02:54 -0400)
committerTom Clegg <tom@curoverse.com>
Tue, 7 Jul 2015 15:41:54 +0000 (11:41 -0400)
services/api/Rakefile
services/api/db/structure.sql

index 22b25313a5f9536764a7838ada2cb4222ebe0225..fbbf53e3c6ac3d1c247b556db29f2f23141c4285 100644 (file)
@@ -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
index 0eef6b4b65e40d6f4448e559d76b7a70b8476967..01bb4172f1963cb12ddc557e2904eb021237a10d 100644 (file)
@@ -19,7 +19,7 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
 --
 
-COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
+-- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
 
 
 SET search_path = public, pg_catalog;