I think we are now in the clear!
We noticed that we needed to migrate columns in other tables that referenced notification_id in addition to just notifications.id itself. Othwerwise, services/notifications.rb
or services/badge_granter.rb
would throw errors.
For any other big forum setup who runs into this in the future with notifications, here is what we did…
All together, we had to migrate four columns in four tables:
notifications.id
user.seen_notification_id
user_badges.notification_id
shelved_notifications.notification_id
We initially went about #1 with the ALTER command suggested above, but then as mentioned opted to use ActiveRecord migrations, that way the migration files add up to the schema.
20230215070319_change_notifications_id_to_bigint.rb
# frozen_string_literal: true
class ChangeNotificationsIdToBigint < ActiveRecord::Migration[6.1]
def change
change_column :notifications, :id, :bigint
end
end
20230215070320_change_user_seen_notification_id_to_bigint.rb
# frozen_string_literal: true
class ChangeUserSeenNotificationIdToBigint < ActiveRecord::Migration[6.1]
def change
change_column :users, :seen_notification_id, :bigint
end
end
20230215070321_change_user_badges_notification_id_to_bigint.rb
# frozen_string_literal: true
class ChangeUserBadgesNotificationIdToBigint < ActiveRecord::Migration[6.1]
def change
change_column :user_badges, :notification_id, :bigint
end
end
20230215070322_change_shelved_notifications_notification_id_to_bigint.rb
# frozen_string_literal: true
class ChangeShelvedNotificationsNotificationIdToBigint < ActiveRecord::Migration[6.1]
def change
change_column :shelved_notifications, :notification_id, :bigint
end
end
We have a custom Dockerfile in our setup (we build images so that we can run discourse and sidekiq on separate resouces in Kubernetes) so getting these files copied into /db/migrate
as part of our Dockerfile was straightforward.
Then, we just let rake db:migrate
handle the rest. Once we did a rolling restart on all of our discourse and sidekiq pods everything was running as expected .