Sha256: bfe1cfe5dc03c0705d7e25e1ca916d5e98c160974c397c32ec3225650548153a

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

require 'rails_pg_extras'

namespace :pg_extras do
  task :establish_connection do
    if ENV['DATABASE_URL'].present?
      ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
    else
      db_config_file = File.read('config/database.yml')
      db_config = YAML::load(ERB.new(db_config_file).result)
      ActiveRecord::Base.establish_connection(db_config[Rails.env])
    end
  end

  RailsPgExtras::QUERIES.each do |query_name|
    desc RubyPgExtras.description_for(query_name: query_name)
    task query_name.to_sym => :establish_connection do
      RailsPgExtras.public_send(query_name)
    end
  end

  desc "Generate a PostgreSQL healthcheck report"
  task diagnose: :establish_connection do
    RailsPgExtras.diagnose
  end

  desc "Display tables metadata metrics"
  task table_info: :establish_connection do
    RailsPgExtras.table_info
  end

  desc "Display indexes metadata metrics"
  task index_info: :establish_connection do
    RailsPgExtras.index_info
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-pg-extras-4.1.0 lib/rails_pg_extras/tasks/all.rake
rails-pg-extras-4.0.1 lib/rails_pg_extras/tasks/all.rake
rails-pg-extras-4.0.0 lib/rails_pg_extras/tasks/all.rake