Sha256: 7c54d3a64fd7019b6e69bbe99d824ad2027e5019212bf3715b2a64ba75d79112
Contents?: true
Size: 965 Bytes
Versions: 1
Compression:
Stored size: 965 Bytes
Contents
Rake::Task['db:structure:dump'].enhance do if ActiveRecord::Base.connection.table_exists?('active_record_views') filename = ENV['DB_STRUCTURE'] || File.join(Rails.root, "db", "structure.sql") if defined? ActiveRecord::Tasks::DatabaseTasks tasks = ActiveRecord::Tasks::DatabaseTasks config = tasks.current_config tasks.send(:class_for_adapter, config.fetch('adapter')).new(config) pg_tasks = tasks.send(:class_for_adapter, config.fetch('adapter')).new(config) pg_tasks.send(:set_psql_env) else config = current_config set_psql_env(config) end system("pg_dump --data-only --table=active_record_views #{Shellwords.escape config['database']} >> #{Shellwords.escape filename}") raise 'active_record_views metadata dump failed' unless $?.success? File.open filename, 'a' do |io| io.puts 'UPDATE active_record_views SET refreshed_at = NULL WHERE refreshed_at IS NOT NULL;' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord_views-0.0.15 | lib/tasks/active_record_views.rake |