X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/f30f230da23603e3c7598205219ce01e9820c470..600a5055b909a46e372c0bfe510bb412d2ccba34:/cookbooks/postgresql/libraries/postgresql.rb?ds=sidebyside diff --git a/cookbooks/postgresql/libraries/postgresql.rb b/cookbooks/postgresql/libraries/postgresql.rb index 266a7b833..5d2007424 100644 --- a/cookbooks/postgresql/libraries/postgresql.rb +++ b/cookbooks/postgresql/libraries/postgresql.rb @@ -93,6 +93,14 @@ class Chef 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|