mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 11:03:41 +08:00
e76c583b91
Having a large number of post-deploy migrations running out-of-numerical-sequence with pre-deploy migrations can be problematic. For example, if we have the sequence - db/migrate/2017... - add column - db/post_migrate/2018... - drop the column - db/migrate/2021... - add the same column again It will work fine in numerical order. But if you run the pre-deploy migrations **followed by** the post-deploy migrations, you will not get the same result. Our post-deploy system is designed to allow for seamless upgrades of Discourse. However, it is reasonable for us to only support this totally seamless experience for a limited period of time. This commit moves all post_deploy migrations which are more than 1 year old (i.e. more than 2 major Discourse versions ago) into the regular pre-deploy migrations directory. This limits the impact of any edge cases caused by out-of-numerical-sequence migrations.
88 lines
1.9 KiB
Ruby
88 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'migration/column_dropper'
|
|
require 'badge_posts_view_manager'
|
|
|
|
class RemoveSuperfluousColumns < ActiveRecord::Migration[5.2]
|
|
DROPPED_COLUMNS ||= {
|
|
user_profiles: %i{
|
|
card_image_badge_id
|
|
},
|
|
categories: %i{
|
|
logo_url
|
|
background_url
|
|
suppress_from_homepage
|
|
},
|
|
groups: %i{
|
|
visible
|
|
public
|
|
alias_level
|
|
},
|
|
theme_fields: %i{target},
|
|
user_stats: %i{first_topic_unread_at},
|
|
topics: %i{
|
|
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
|
|
},
|
|
users: %i{
|
|
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
|
|
},
|
|
user_auth_tokens: %i{legacy},
|
|
user_options: %i{theme_key},
|
|
themes: %i{key},
|
|
email_logs: %i{
|
|
topic_id
|
|
reply_key
|
|
skipped
|
|
skipped_reason
|
|
},
|
|
posts: %i{vote_count}
|
|
}
|
|
|
|
def up
|
|
BadgePostsViewManager.drop!
|
|
|
|
DROPPED_COLUMNS.each do |table, columns|
|
|
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
|