DEV: remove unused columns from posts and topics
avg_time on posts and topics have not been used in a year. This uses a re-runnable ddl transaction diasabled migration to drop the column, cause it touchs very high traffic table and may deadlock
This commit is contained in:
parent
ca539fdccf
commit
310a7edee5
|
@ -10,6 +10,9 @@ class Post < ActiveRecord::Base
|
|||
include HasCustomFields
|
||||
include LimitedEdit
|
||||
|
||||
# remove line Jan 2021
|
||||
self.ignored_columns = ["avg_time"]
|
||||
|
||||
cattr_accessor :plugin_permitted_create_params
|
||||
self.plugin_permitted_create_params = {}
|
||||
|
||||
|
@ -1107,7 +1110,6 @@ end
|
|||
# like_count :integer default(0), not null
|
||||
# incoming_link_count :integer default(0), not null
|
||||
# bookmark_count :integer default(0), not null
|
||||
# avg_time :integer
|
||||
# score :float
|
||||
# reads :integer default(0), not null
|
||||
# post_type :integer default(1), not null
|
||||
|
|
|
@ -10,6 +10,9 @@ class Topic < ActiveRecord::Base
|
|||
include LimitedEdit
|
||||
extend Forwardable
|
||||
|
||||
# remove line Jan 2021
|
||||
self.ignored_columns = ["avg_time"]
|
||||
|
||||
def_delegator :featured_users, :user_ids, :featured_user_ids
|
||||
def_delegator :featured_users, :choose, :feature_topic_users
|
||||
|
||||
|
@ -1567,7 +1570,6 @@ end
|
|||
# featured_user1_id :integer
|
||||
# featured_user2_id :integer
|
||||
# featured_user3_id :integer
|
||||
# avg_time :integer
|
||||
# deleted_at :datetime
|
||||
# highest_post_number :integer default(0), not null
|
||||
# image_url :string
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveAvgTimeFromTopicsPosts < ActiveRecord::Migration[6.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
# this makes it re-runnable and also works if it was not created initially
|
||||
execute <<~SQL
|
||||
ALTER TABLE topics DROP COLUMN IF EXISTS avg_time CASCADE
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
ALTER TABLE posts DROP COLUMN IF EXISTS avg_time CASCADE
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
# do nothing re-runnable
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue