Dev fix some types (#29547)

The primary key is usually a bigint column, but the foreign key columns
are usually of integer type. This can lead to issues when joining these
columns due to mismatched types and different value ranges.

This was using a temporary plugin / test API to make tests pass. After
more careful consideration, we concluded that it is safe to alter the
tables directly.
This commit is contained in:
Bianca Nenciu 2024-11-01 19:19:25 +02:00 committed by GitHub
parent 09e16a3c0d
commit 723dc1fa55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -206,7 +206,7 @@ end
# reminder_set_at :datetime
# auto_delete_preference :integer default(0), not null
# pinned :boolean default(FALSE)
# bookmarkable_id :integer
# bookmarkable_id :bigint
# bookmarkable_type :string
#
# Indexes

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
class AlterBookmarksIdsToBigint < ActiveRecord::Migration[7.1]
def up
change_column :bookmarks, :bookmarkable_id, :bigint
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -476,9 +476,6 @@ RSpec.configure do |config|
Capybara::Selenium::Driver.new(app, **mobile_driver_options)
end
migrate_column_to_bigint(AllowedPmUser, :allowed_pm_user_id)
migrate_column_to_bigint(Bookmark, :bookmarkable_id)
migrate_column_to_bigint(IgnoredUser, :ignored_user_id)
migrate_column_to_bigint(PostAction, :post_action_type_id)
migrate_column_to_bigint(Reviewable, :target_id)
migrate_column_to_bigint(ReviewableHistory, :reviewable_id)