diff --git a/app/models/search_log.rb b/app/models/search_log.rb index 80068d3414b..c74d97bb0fb 100644 --- a/app/models/search_log.rb +++ b/app/models/search_log.rb @@ -41,6 +41,7 @@ class SearchLog < ActiveRecord::Base search_type = search_types[search_type] return [:error] unless search_type.present? && ip_address.present? + ip_address = nil if user_id key = redis_key(user_id: user_id, ip_address: ip_address) result = nil @@ -143,7 +144,7 @@ end # id :integer not null, primary key # term :string not null # user_id :integer -# ip_address :inet not null +# ip_address :inet # search_result_id :integer # search_type :integer not null # created_at :datetime not null diff --git a/db/migrate/20180521184439_allow_null_ip_search_log.rb b/db/migrate/20180521184439_allow_null_ip_search_log.rb new file mode 100644 index 00000000000..19566c4d9f2 --- /dev/null +++ b/db/migrate/20180521184439_allow_null_ip_search_log.rb @@ -0,0 +1,13 @@ +class AllowNullIpSearchLog < ActiveRecord::Migration[5.1] + def up + begin + Migration::SafeMigrate.disable! + change_column :search_logs, :ip_address, :inet, null: true + ensure + Migration::SafeMigrate.enable! + end + end + + def down + end +end