2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-08 15:47:38 +08:00
|
|
|
require 'migration/column_dropper'
|
|
|
|
require 'badge_posts_view_manager'
|
|
|
|
|
|
|
|
class RemoveSuperfluousColumns < ActiveRecord::Migration[5.2]
|
2019-08-08 22:06:27 +08:00
|
|
|
DROPPED_COLUMNS ||= {
|
|
|
|
user_profiles: %i{
|
2018-10-08 15:47:38 +08:00
|
|
|
card_image_badge_id
|
|
|
|
},
|
2019-08-08 22:06:27 +08:00
|
|
|
categories: %i{
|
2018-10-08 15:47:38 +08:00
|
|
|
logo_url
|
|
|
|
background_url
|
|
|
|
suppress_from_homepage
|
|
|
|
},
|
2019-08-08 22:06:27 +08:00
|
|
|
groups: %i{
|
2018-10-08 15:47:38 +08:00
|
|
|
visible
|
|
|
|
public
|
|
|
|
alias_level
|
|
|
|
},
|
2019-08-08 22:06:27 +08:00
|
|
|
theme_fields: %i{target},
|
|
|
|
user_stats: %i{first_topic_unread_at},
|
|
|
|
topics: %i{
|
2018-10-08 15:47:38 +08:00
|
|
|
auto_close_at
|
|
|
|
auto_close_user_id
|
|
|
|
auto_close_started_at
|
|
|
|
auto_close_based_on_last_post
|
|
|
|
auto_close_hours
|
|
|
|
inappropriate_count
|
|
|
|
bookmark_count
|
|
|
|
off_topic_count
|
|
|
|
illegal_count
|
|
|
|
notify_user_count
|
|
|
|
last_unread_at
|
|
|
|
vote_count
|
|
|
|
},
|
2019-08-08 22:06:27 +08:00
|
|
|
users: %i{
|
2018-10-08 15:47:38 +08:00
|
|
|
email
|
|
|
|
email_always
|
|
|
|
mailing_list_mode
|
|
|
|
email_digests
|
|
|
|
email_direct
|
|
|
|
email_private_messages
|
|
|
|
external_links_in_new_tab
|
|
|
|
enable_quoting
|
|
|
|
dynamic_favicon
|
|
|
|
disable_jump_reply
|
|
|
|
edit_history_public
|
|
|
|
automatically_unpin_topics
|
|
|
|
digest_after_days
|
|
|
|
auto_track_topics_after_msecs
|
|
|
|
new_topic_duration_minutes
|
|
|
|
last_redirected_to_top_at
|
|
|
|
auth_token
|
|
|
|
auth_token_updated_at
|
|
|
|
blocked
|
|
|
|
silenced
|
|
|
|
trust_level_locked
|
|
|
|
},
|
2019-08-08 22:06:27 +08:00
|
|
|
user_auth_tokens: %i{legacy},
|
|
|
|
user_options: %i{theme_key},
|
|
|
|
themes: %i{key},
|
|
|
|
email_logs: %i{
|
2018-10-08 15:47:38 +08:00
|
|
|
topic_id
|
|
|
|
reply_key
|
|
|
|
skipped
|
|
|
|
skipped_reason
|
|
|
|
},
|
2019-08-08 22:06:27 +08:00
|
|
|
posts: %i{vote_count}
|
|
|
|
}
|
|
|
|
|
|
|
|
def up
|
|
|
|
BadgePostsViewManager.drop!
|
|
|
|
|
|
|
|
DROPPED_COLUMNS.each do |table, columns|
|
2018-10-08 15:47:38 +08:00
|
|
|
Migration::ColumnDropper.execute_drop(table, columns)
|
|
|
|
end
|
|
|
|
|
|
|
|
DB.exec "DROP FUNCTION IF EXISTS first_unread_topic_for(int)"
|
|
|
|
|
|
|
|
BadgePostsViewManager.create!
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
raise ActiveRecord::IrreversibleMigration
|
|
|
|
end
|
|
|
|
end
|