Maintenance: Make sure that the column schema is resetted on db reset to prevent old schema because of different branches or custom developments.
This commit is contained in:
parent
5163888b70
commit
a7bc54db37
1 changed files with 8 additions and 3 deletions
|
@ -11,16 +11,21 @@ namespace :zammad do
|
||||||
# execute them and their prerequisites multiple times (in tests)
|
# execute them and their prerequisites multiple times (in tests)
|
||||||
# there is no way in rake to achieve that
|
# there is no way in rake to achieve that
|
||||||
%w[db:drop:_unsafe db:create db:migrate db:seed zammad:db:rebuild].each do |task|
|
%w[db:drop:_unsafe db:create db:migrate db:seed zammad:db:rebuild].each do |task|
|
||||||
|
case task
|
||||||
|
when 'db:migrate'
|
||||||
|
|
||||||
if task == 'db:drop:_unsafe'
|
# make sure that old column schemas are getting dropped to prevent
|
||||||
|
# wrong schema for new db setup
|
||||||
|
ActiveRecord::Base.descendants.each(&:reset_column_information)
|
||||||
|
|
||||||
|
$stdout = StringIO.new
|
||||||
|
when 'db:drop:_unsafe'
|
||||||
# ensure all DB connections are closed before dropping the DB
|
# ensure all DB connections are closed before dropping the DB
|
||||||
# since Rails > 5.2 two connections are present (after `db:migrate`) that
|
# since Rails > 5.2 two connections are present (after `db:migrate`) that
|
||||||
# block dropping the DB for PostgreSQL
|
# block dropping the DB for PostgreSQL
|
||||||
ActiveRecord::Base.connection_handler.connection_pools.each(&:disconnect!)
|
ActiveRecord::Base.connection_handler.connection_pools.each(&:disconnect!)
|
||||||
end
|
end
|
||||||
|
|
||||||
$stdout = StringIO.new if task == 'db:migrate'.freeze
|
|
||||||
|
|
||||||
Rake::Task[task].reenable
|
Rake::Task[task].reenable
|
||||||
Rake::Task[task].invoke
|
Rake::Task[task].invoke
|
||||||
ensure
|
ensure
|
||||||
|
|
Loading…
Reference in a new issue