mastodon/app/models/account_stat.rb
Claire 8569126c2e
Fix upgrade path from 3.4.0 (#16465)
3.4.1 dropped account_stats.lock_version, but in a way breaking the usual
upgrade path by requiring services to be reloaded after the post-migrations.

Indeed, `self.locking_column = nil` was not enough for Rails to ignore the
`lock_version` column when preparing statements on application load, resulting
in some ActiveRecord queries (typically those involving
`includes(:account_stat)`) erroring out with:

  ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR:  column account_stats.lock_version does not exist
2021-07-07 21:13:30 +02:00

24 lines
697 B
Ruby

# frozen_string_literal: true
# == Schema Information
#
# Table name: account_stats
#
# id :bigint(8) not null, primary key
# account_id :bigint(8) not null
# statuses_count :bigint(8) default(0), not null
# following_count :bigint(8) default(0), not null
# followers_count :bigint(8) default(0), not null
# created_at :datetime not null
# updated_at :datetime not null
# last_status_at :datetime
#
class AccountStat < ApplicationRecord
self.locking_column = nil
self.ignored_columns = %w(lock_version)
belongs_to :account, inverse_of: :account_stat
update_index('accounts#account', :account)
end