错误:整数超出范围

我认为我们现在安全了!

我们注意到,除了 notifications.id 本身之外,还需要迁移其他引用 notification_id 的表中的列。否则,services/notifications.rb 或 services/badge_granter.rb 将会抛出错误。


对于将来遇到此问题的任何其他大型论坛设置,我们是这样做的……

总共,我们需要迁移四个表中的四列:

  1. notifications.id
  2. user.seen_notification_id
  3. user_badges.notification_id
  4. shelved_notifications.notification_id

我们最初使用上面建议的 ALTER 命令来处理 #1,但后来如上所述,我们选择使用 ActiveRecord 迁移,这样迁移文件就会累加到 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

我们在设置中有一个自定义的 Dockerfile(我们构建镜像,以便在 Kubernetes 上的不同资源上运行 discourse 和 sidekiq),因此将这些文件作为 Dockerfile 的一部分复制到 /db/migrate 中非常简单。

然后,我们只需让 rake db:migrate 处理其余的事情。一旦我们对所有 discourse 和 sidekiq pod 进行了滚动重启,一切都按预期运行了 :crossed_fingers:。

3 个赞