Sha256: 4cf7af8e9284e5ce1220e8903018ed79107d893bb304c8352c4cb85492ca9e4f

Contents?: true

Size: 821 Bytes

Versions: 3

Compression:

Stored size: 821 Bytes

Contents

require "backhoe"

namespace :db do
  desc "Dump the current database to db/data.sql"
  task :dump => :environment do
    Backhoe.dump
  end

  desc "Load the db/data.sql data into the current database."
  task :load => ["db:drop:current", "db:create:current"] do
    Backhoe.load
  end
end

# FIXME is this necessary? Why can't we just rely on RAILS_ENV?
if defined?(ActiveRecord)
  namespace :db do
    namespace :create do
      task :current => :load_config do
        config = ActiveRecord::Tasks::DatabaseTasks.current_config
        ActiveRecord::Tasks::DatabaseTasks.create config
      end
    end

    namespace :drop do
      task :current => :load_config do
        config = ActiveRecord::Tasks::DatabaseTasks.current_config
        ActiveRecord::Tasks::DatabaseTasks.drop config
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bard-rake-0.17.0 lib/bard/rake/db_dump_load.rb
bard-rake-0.16.1 lib/bard/rake/db_dump_load.rb
bard-rake-0.16.0 lib/bard/rake/db_dump_load.rb