Sha256: 239747c5dc918f2f3abb877c7577dda67390b55887a3f6128e4acf9009fd053e

Contents?: true

Size: 892 Bytes

Versions: 10

Compression:

Stored size: 892 Bytes

Contents

module ActsAsArchive
  module Base
    module Adapters
      module PostgreSQL

        private

        def archive_table_indexed_columns
          # This query comes courtesy of cope360:
          # http://stackoverflow.com/questions/2204058/show-which-columns-an-index-is-on-in-postgresql/2213199#2213199
          index_query = <<-SQL
select
    t.relname as table_name,
    i.relname as index_name,
    a.attname as column_name
from
    pg_class t,
    pg_class i,
    pg_index ix,
    pg_attribute a
where
    t.oid = ix.indrelid
    and i.oid = ix.indexrelid
    and a.attrelid = t.oid
    and a.attnum = ANY(ix.indkey)
    and t.relkind = 'r'
    and t.relname = 'archived_#{table_name}'
order by
    t.relname,
    i.relname
SQL

          indexes = connection.select_all(index_query).collect do |r|
            r["column_name"]
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
brianjlandau-acts_as_archive-0.2.8 lib/acts_as_archive/base/adapters/postgresql.rb
brianjlandau-acts_as_archive-0.2.7 lib/acts_as_archive/base/adapters/postgresql.rb
brianjlandau-acts_as_archive-0.2.6 lib/acts_as_archive/base/adapters/postgresql.rb
micahwedemeyer-acts_as_archive-0.3.0 lib/acts_as_archive/base/adapters/postgresql.rb
sideshowbandana-acts_as_archive-0.2.7 lib/acts_as_archive/base/adapters/postgresql.rb
sideshowbandana-acts_as_archive-0.2.6 lib/acts_as_archive/base/adapters/postgresql.rb
acts_as_archive-0.2.5 lib/acts_as_archive/base/adapters/postgresql.rb
acts_as_archive-0.2.4 lib/acts_as_archive/base/adapters/postgresql.rb
acts_as_archive-0.2.3 lib/acts_as_archive/base/adapters/postgresql.rb
acts_as_archive-0.2.2 lib/acts_as_archive/base/adapters/postgresql.rb