PERF: Store `EmailLog#bounce_key` as `uuid` data type. (#6093)
PERF: Store `EmailLog#bounce_key` as `uuid` data type.
This commit is contained in:
parent
f3868fd646
commit
c0c263405a
|
@ -67,6 +67,10 @@ class EmailLog < ActiveRecord::Base
|
||||||
.try(:to_address)
|
.try(:to_address)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bounce_key
|
||||||
|
super&.delete('-')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class AlterBounceKeyOnEmailLogs < ActiveRecord::Migration[5.2]
|
||||||
|
def up
|
||||||
|
change_column :email_logs, :bounce_key, 'uuid USING bounce_key::uuid'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_column :email_logs, :bounce_key, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -101,4 +101,19 @@ describe EmailLog do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#bounce_key' do
|
||||||
|
it 'should format the bounce key correctly' do
|
||||||
|
bounce_key = SecureRandom.hex
|
||||||
|
email_log = Fabricate(:email_log, user: user, bounce_key: bounce_key)
|
||||||
|
|
||||||
|
raw_bounce_key = EmailLog.where(id: email_log.id)
|
||||||
|
.pluck("bounce_key::text")
|
||||||
|
.first
|
||||||
|
|
||||||
|
expect(raw_bounce_key).to_not eq(bounce_key)
|
||||||
|
expect(raw_bounce_key.delete('-')).to eq(bounce_key)
|
||||||
|
expect(EmailLog.find(email_log.id).bounce_key).to eq(bounce_key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue