From 4f11d16deb6dc51e43e4f613bd7ef16498ab1bad Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Tue, 19 Nov 2024 21:22:02 +0200 Subject: [PATCH] DEV: Remove migrate_column_to_bigint spec helper (#29805) This spec helper was introduced as a temporary solution to the problem of mismatched types between primary key and foreign key columns. All plugins have been migrated and the only remaining use of this helper is in core Discourse. --- spec/rails_helper.rb | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1133ee99496..9f143f6bd85 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -476,23 +476,19 @@ RSpec.configure do |config| Capybara::Selenium::Driver.new(app, **mobile_driver_options) end - migrate_column_to_bigint(PostAction, :post_action_type_id) - migrate_column_to_bigint(Reviewable, :target_id) - migrate_column_to_bigint(ReviewableHistory, :reviewable_id) - migrate_column_to_bigint(ReviewableScore, :reviewable_id) - migrate_column_to_bigint(ReviewableScore, :reviewable_score_type) - migrate_column_to_bigint(SidebarSectionLink, :linkable_id) - migrate_column_to_bigint(SidebarSectionLink, :sidebar_section_id) - migrate_column_to_bigint(User, :last_seen_reviewable_id) - migrate_column_to_bigint(User, :required_fields_version) - - $columns_to_migrate_to_bigint.each do |model, column| - if model.is_a?(String) - DB.exec("ALTER TABLE #{model} ALTER #{column} TYPE bigint") - else - DB.exec("ALTER TABLE #{model.table_name} ALTER #{column} TYPE bigint") - model.reset_column_information - end + [ + [PostAction, :post_action_type_id], + [Reviewable, :target_id], + [ReviewableHistory, :reviewable_id], + [ReviewableScore, :reviewable_id], + [ReviewableScore, :reviewable_score_type], + [SidebarSectionLink, :linkable_id], + [SidebarSectionLink, :sidebar_section_id], + [User, :last_seen_reviewable_id], + [User, :required_fields_version], + ].each do |model, column| + DB.exec("ALTER TABLE #{model.table_name} ALTER #{column} TYPE bigint") + model.reset_column_information end # Sets sequence's value to be greater than the max value that an INT column can hold. This is done to prevent @@ -1050,10 +1046,6 @@ def apply_base_chrome_options(options) end end -def migrate_column_to_bigint(model, column) - ($columns_to_migrate_to_bigint ||= []) << [model, column] -end - class SpecSecureRandom class << self attr_accessor :value