¡Creo que ya estamos fuera de peligro!
Nos dimos cuenta de que necesitábamos migrar columnas en otras tablas que hacían referencia a notification_id además de notifications.id en sí. De lo contrario, services/notifications.rb o services/badge_granter.rb lanzarían errores.
Para cualquier otra configuración de foro grande que se encuentre con esto en el futuro con las notificaciones, esto es lo que hicimos…
En total, tuvimos que migrar cuatro columnas en cuatro tablas:
notifications.id
user.seen_notification_id
user_badges.notification_id
shelved_notifications.notification_id
Inicialmente, abordamos el punto 1 con el comando ALTER sugerido anteriormente, pero luego, como se mencionó, optamos por usar migraciones de ActiveRecord, de esa manera los archivos de migración se suman al esquema.
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
Tenemos un Dockerfile personalizado en nuestra configuración (construimos imágenes para poder ejecutar discourse y sidekiq en recursos separados en Kubernetes), por lo que copiar estos archivos a /db/migrate como parte de nuestro Dockerfile fue sencillo.
Luego, simplemente dejamos que rake db:migrate se encargara del resto. Una vez que hicimos un reinicio escalonado de todos nuestros pods de discourse y sidekiq, todo funcionaba como se esperaba
.