FIX: Change default for IncomingEmail#created_via to 0 (unknown) and make NOT NULL (#11782)

Follow up to https://review.discourse.org/t/dev-add-created-via-column-to-incomingemail-pr-11751/18366/6
This commit is contained in:
Martin Brennan
2021-01-21 12:59:50 +10:00
committed by GitHub
parent 9d287f5ff9
commit 9ee8a01c3a
4 changed files with 20 additions and 2 deletions

View File

@ -6,6 +6,8 @@ class IncomingEmail < ActiveRecord::Base
belongs_to :post
belongs_to :group, foreign_key: :imap_group_id, class_name: 'Group'
validates :created_via, presence: true
scope :errored, -> { where("NOT is_bounce AND error IS NOT NULL") }
scope :addressed_to, -> (email) do
@ -33,6 +35,7 @@ class IncomingEmail < ActiveRecord::Base
def self.created_via_types
@types ||= Enum.new(
unknown: 0,
handle_mail: 1,
pop3_poll: 2,
imap: 3,
@ -106,7 +109,7 @@ end
# imap_uid :integer
# imap_sync :boolean
# imap_group_id :bigint
# created_via :integer
# created_via :integer default(0), not null
#
# Indexes
#