2018-10-02 14:25:04 +00:00
|
|
|
namespace :zammad do
|
|
|
|
|
|
|
|
namespace :db do
|
|
|
|
|
2018-10-18 12:20:51 +00:00
|
|
|
desc 'Drops, recreates and seeds the database, clears the Cache and reloads the Settings'
|
2018-10-02 14:25:04 +00:00
|
|
|
task reset: :environment do
|
2018-10-18 12:20:51 +00:00
|
|
|
|
|
|
|
# we loop over each dependent task to be able to
|
|
|
|
# execute them and their prerequisites multiple times (in tests)
|
|
|
|
# there is no way in rake to achive that
|
|
|
|
%w[db:drop:_unsafe db:create db:schema:load db:seed].each do |task|
|
|
|
|
|
|
|
|
begin
|
|
|
|
$stdout = StringIO.new if task == 'db:schema:load'.freeze
|
|
|
|
|
|
|
|
Rake::Task[task].reenable
|
|
|
|
Rake::Task[task].invoke
|
|
|
|
ensure
|
|
|
|
$stdout = STDOUT
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ActiveRecord::Base.connection.reconnect!
|
2018-10-02 14:25:04 +00:00
|
|
|
Cache.clear
|
|
|
|
Setting.reload
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|