Improved migration to work also with postgresql.

This commit is contained in:
Martin Edenhofer 2017-09-26 14:00:34 +02:00
parent f91536ff39
commit 46c85048fd

View file

@ -1,6 +1,8 @@
# Rails dropped the class
# ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::MysqlDateTime
# via: https://github.com/rails/rails/commit/f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7
# ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer
# via: https://github.com/rails/rails/commit/aafee233fb3b4211ee0bfb1fca776c159bd1067e
# which we use in stored Cti::Log instance preferences.
# Since we don't need the instances but just an Hash we have to:
# - create a dummy class
@ -17,12 +19,23 @@ module ActiveRecord
end
end
end
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module OID
class Integer < Type::Integer
end
end
end
end
end
class CtiLogPreferencesMigration < ActiveRecord::Migration[5.0]
def change
# correct all entries
Cti::Log.all.each do |item|
Cti::Log.all.pluck(:id).each do |item_id|
item = Cti::Log.find(item_id)
next if !item.preferences
next if item.preferences.blank?