Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 28 lines (26 sloc) 836 Bytes
require 'sinatra/activerecord/rake'
require './orngus'
namespace :db do
desc "Truncate all existing data"
task :reset do
begin
config = @@db
case config["adapter"]
when "mysql", "postgresql"
ActiveRecord::Base.connection.tables.each do |table|
unless table=='schema_migrations'
ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
end
end
when "sqlite", "sqlite3"
ActiveRecord::Base.connection.tables.each do |table|
unless table=='schema_migrations'
ActiveRecord::Base.connection.execute("DELETE FROM #{table}")
ActiveRecord::Base.connection.execute("DELETE FROM sqlite_sequence where name='#{table}'")
end
end
ActiveRecord::Base.connection.execute("VACUUM")
end
end
end
end
Something went wrong with that request. Please try again.