Sha256: 6ba456f33304281c882786fb66bde313b50d30824304a96e3bd51f438cbacde0

Contents?: true

Size: 836 Bytes

Versions: 6

Compression:

Stored size: 836 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/data.sql", "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

6 entries across 6 versions & 1 rubygems

Version Path
bard-rake-0.18.2 lib/bard/rake/db_dump_load.rb
bard-rake-0.18.1 lib/bard/rake/db_dump_load.rb
bard-rake-0.18.0 lib/bard/rake/db_dump_load.rb
bard-rake-0.17.3 lib/bard/rake/db_dump_load.rb
bard-rake-0.17.2 lib/bard/rake/db_dump_load.rb
bard-rake-0.17.1 lib/bard/rake/db_dump_load.rb