2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2016-11-25 14:54:13 +00:00
|
|
|
|
|
|
|
class DbHelper
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
execute post database statements after import (e. g. reset primary key sequences for postgresql)
|
|
|
|
|
|
|
|
DbHelper.import_post
|
|
|
|
|
2019-07-31 08:23:48 +00:00
|
|
|
or only for certain tables
|
2016-11-25 14:54:13 +00:00
|
|
|
|
|
|
|
DbHelper.import_post(table_name)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.import_post(table = nil)
|
|
|
|
return if ActiveRecord::Base.connection_config[:adapter] != 'postgresql'
|
|
|
|
|
|
|
|
tables = if table
|
|
|
|
[table]
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.tables
|
|
|
|
end
|
|
|
|
|
|
|
|
tables.each do |t|
|
|
|
|
ActiveRecord::Base.connection.reset_pk_sequence!(t)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|