Skip to content

Instantly share code, notes, and snippets.

@tannakartikey
Last active August 11, 2023 16:08
Show Gist options
  • Save tannakartikey/670075606f9284f3b6e5c90bb340265b to your computer and use it in GitHub Desktop.
Save tannakartikey/670075606f9284f3b6e5c90bb340265b to your computer and use it in GitHub Desktop.
Destroy the schema and re-create the database from scratch
namespace :db do
desc 'reset the database by dropping the schema'
task complete_reset: :environment do
raise unless Rails.env.local?
FileUtils.rm_f('db/schema.rb')
Rake::Task['db:drop'].invoke
Rake::Task['db:create'].invoke
Rake::Task['db:migrate'].invoke
Rake::Task['db:seed'].invoke
Rake::Task['dev:prime'].invoke
end
end
@aliccardo
Copy link

aliccardo commented Aug 8, 2023

thank you!
Can I suggest to clear also the schema cache with Rake::Task['db:schema:cache:clear'].invoke?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment