```ruby
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")
    config = current_config
    set_psql_env(config)
    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?
  end
end
```

Fix structure dumping on Rails 4.2
user
```ruby
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?
  end
end
```
assistant