Sha256: 0eaf65d437a2fcf9f40ff775d81d0ff33922615a9e151a5fa256197b95ec163f

Contents?: true

Size: 773 Bytes

Versions: 10

Compression:

Stored size: 773 Bytes

Contents

namespace :db do
  desc 'Remove and install new database from scratch'
  task :install => [:drop_redis, :drop_tables, :'db:migrate', :'db:seed'] do
  end

  task :drop_redis => :environment do
    puts "Clearing Redis"
    Redis.current.flushdb
  end

  task :drop_tables => :environment do
    puts "Droping all tables..."
    puts "-"*10

    ActiveRecord::Base.connection.drop_table "schema_migrations"

    root   = File.expand_path('../../../app/models/', __FILE__)
    models = Dir["#{root}/**"].each{|x| require x; }
    tables = ActiveRecord::Base.connection.tables

    ActiveRecord::Base.subclasses.map{|x| x.table_name}.each do |x|
      ActiveRecord::Base.connection.drop_table x if tables.include? x
      puts "#{x} droped;"
    end
    puts "-"*10
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
smartkiosk-server-0.10.5 lib/tasks/db.rake
smartkiosk-server-0.10.4 lib/tasks/db.rake
smartkiosk-server-0.10.3 lib/tasks/db.rake
smartkiosk-server-0.10.2 lib/tasks/db.rake
smartkiosk-server-0.10.1 lib/tasks/db.rake
smartkiosk-server-0.10.0 lib/tasks/db.rake
smartkiosk-server-0.9.3 lib/tasks/db.rake
smartkiosk-server-0.9.2 lib/tasks/db.rake
smartkiosk-server-0.9.1 lib/tasks/db.rake
smartkiosk-server-0.9.0 lib/tasks/db.rake