Skip to content

Instantly share code, notes, and snippets.

@huzaifa-malik
huzaifa-malik / db.rake
Created July 10, 2017 07:35 — forked from carpeliam/db.rake
dump, load, or clear a mysql database for a rails project
namespace :db do
desc "Clear all tables"
task :clear => :environment do
conn = ActiveRecord::Base.connection
conn.tables.select{|t| t.start_with? ActiveRecord::Base.table_name_prefix }.each do |t|
conn.drop_table t
end
end
desc "Dump database into an SQL file"