Sha256: 5b21b92238c1e457e04a7346f614ced55c5c68f6fb98911d2bc37cc5f2ffc398

Contents?: true

Size: 725 Bytes

Versions: 2

Compression:

Stored size: 725 Bytes

Contents

namespace :db do

  def mysql_execute(database, command)
    system "echo \"#{command}\" | mysql #{database}"
  end

  def mysql_load(database, file)
    system "mysql #{database} < #{file}"
  end

  def mysql_admin(*args)
    system "mysqladmin #{args.join(' ')}"
  end

  namespace :test do
    task :prepare => 'db:test:load'

    task :load => 'db:test:purge' do
      mysql_admin :create, 'rivendell_test'
      mysql_load 'rivendell_test', 'db/schema.sql'
      mysql_execute :mysql, "GRANT ALL PRIVILEGES ON rivendell_test.* TO 'rduser'@'localhost' IDENTIFIED BY 'letmein';"
      puts 'Database "rivendell_test" created'
    end

    task :purge do
      mysql_admin :drop, '--force rivendell_test'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rivendell-db-0.4 tasks/db.rake
rivendell-db-0.3 tasks/db.rake