Sha256: f619adae4f6d45e1bd52a827fbb8c4b6e9a658dfac8e20d6bf40abfbacf8b03c

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Demo::Application.load_tasks

Rake::Task['db:test:prepare'].clear_prerequisites
Rake::Task['db:test:prepare'].enhance [:environment, :load_config]

Rake::Task['db:test:clone_structure'].clear
Rake.application.instance_variable_get('@tasks').delete('db:test:clone_structure')
namespace :db do
  namespace :test do
    desc "Prepare test db by migrating"
    task :clone_structure => [:environment, :load_config] do
	    ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
	    ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_path)
    end
  end
end

namespace :db do
  desc "Drop all tables"
  task :drop_tables => :environment do
    conn = ActiveRecord::Base.connection
    tables = conn.execute("show tables").map { |r| r[0] }
    #tables.delete "schema_migrations"
    tables.each { |t| conn.execute("DROP TABLE #{t}") }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kojac-0.17.0 spec/demo/Rakefile
kojac-0.16.0 spec/demo/Rakefile
kojac-0.15.0 spec/demo/Rakefile
kojac-0.13.0 spec/demo/Rakefile
kojac-0.12.0 spec/demo/Rakefile
kojac-0.11.0 spec/demo/Rakefile