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)
|
2020-08-13 07:47:51 +00:00
|
|
|
# there is no way in rake to achieve that
|
2020-08-19 08:32:00 +00:00
|
|
|
%w[db:drop:_unsafe db:create db:migrate db:seed].each do |task|
|
2018-10-18 12:20:51 +00:00
|
|
|
|
2020-08-19 08:32:00 +00:00
|
|
|
$stdout = StringIO.new if task == 'db:migrate'.freeze
|
2019-06-27 18:26:28 +00:00
|
|
|
|
|
|
|
Rake::Task[task].reenable
|
|
|
|
Rake::Task[task].invoke
|
|
|
|
ensure
|
|
|
|
$stdout = STDOUT
|
2018-10-18 12:20:51 +00:00
|
|
|
end
|
|
|
|
|
2020-08-18 12:46:13 +00:00
|
|
|
Package::Migration.linked
|
2018-10-18 12:20:51 +00:00
|
|
|
ActiveRecord::Base.connection.reconnect!
|
2020-08-13 07:47:51 +00:00
|
|
|
ActiveRecord::Base.descendants.each(&:reset_column_information)
|
2018-10-02 14:25:04 +00:00
|
|
|
Cache.clear
|
|
|
|
Setting.reload
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|