]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/postgresql/libraries/postgresql.rb
add function to create and delete tablespaces
[chef.git] / cookbooks / postgresql / libraries / postgresql.rb
index 266a7b83387182f5a7b81c730ee3e53cb5abf37d..5d20074249d9e98da909620299451809dce80b78 100644 (file)
@@ -93,6 +93,14 @@ class Chef
       end
     end
 
       end
     end
 
+    def tablespaces
+      @tablespaces ||= query("SELECT spcname, usename FROM pg_tablespace AS t INNER JOIN pg_user AS u ON t.spcowner = u.usesysid").each_with_object({}) do |tablespace, tablespaces|
+        tablespaces[tablespace[:spcname]] = {
+          :owner => tablespace[:usename]
+        }
+      end
+    end
+
     def tables(database)
       @tables ||= {}
       @tables[database] ||= query("SELECT n.nspname, c.relname, u.usename, c.relacl FROM pg_class AS c INNER JOIN pg_user AS u ON c.relowner = u.usesysid INNER JOIN pg_namespace AS n ON c.relnamespace = n.oid", :database => database).each_with_object({}) do |table, tables|
     def tables(database)
       @tables ||= {}
       @tables[database] ||= query("SELECT n.nspname, c.relname, u.usename, c.relacl FROM pg_class AS c INNER JOIN pg_user AS u ON c.relowner = u.usesysid INNER JOIN pg_namespace AS n ON c.relnamespace = n.oid", :database => database).each_with_object({}) do |table, tables|