Sha256: cbd654e5c06d4b173b0d10ca617744012838bc8a65b840fc34cd61f5324d6f39

Contents?: true

Size: 784 Bytes

Versions: 29

Compression:

Stored size: 784 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" rescue nil

    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

29 entries across 29 versions & 1 rubygems

Version Path
smartkiosk-server-0.10.15 lib/tasks/db.rake
smartkiosk-server-0.10.14 lib/tasks/db.rake
smartkiosk-server-0.10.13 lib/tasks/db.rake
smartkiosk-server-0.10.12 lib/tasks/db.rake
smartkiosk-server-0.10.11 lib/tasks/db.rake
smartkiosk-server-0.10.10 lib/tasks/db.rake
smartkiosk-server-0.10.9 lib/tasks/db.rake
smartkiosk-server-0.10.8 lib/tasks/db.rake
smartkiosk-server-0.10.7 lib/tasks/db.rake