# typed: strict
class Domain::Twitter::Tweet < ReduxApplicationRecord
  self.table_name = "domain_twitter_tweets"

  belongs_to :author,
             class_name: "::Domain::Twitter::User",
             foreign_key: :author_id,
             primary_key: :tw_id

  has_many :medias, class_name: "Domain::Twitter::Media", foreign_key: :tweet_id

  enum :state, %i[ok error]
  after_initialize do
    self.state ||= "ok"
    self.state_detail ||= {}
    self.raw_data ||= {}
  end
end
