Merge remote-tracking branch 'upstream/pull/5304'
This commit is contained in:
commit
708603801a
2 changed files with 16 additions and 0 deletions
15
db/migrate/20241023004427_backfill_note_subscriptions.rb
Normal file
15
db/migrate/20241023004427_backfill_note_subscriptions.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
class BackfillNoteSubscriptions < ActiveRecord::Migration[7.2]
|
||||||
|
class NoteComment < ApplicationRecord; end
|
||||||
|
class NoteSubscription < ApplicationRecord; end
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
attrs = %w[user_id note_id]
|
||||||
|
|
||||||
|
NoteComment.in_batches(:of => 1000) do |note_comments|
|
||||||
|
rows = note_comments.distinct.where.not(:author_id => nil).pluck(:author_id, :note_id)
|
||||||
|
NoteSubscription.upsert_all(rows.map { |r| attrs.zip(r).to_h })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3397,6 +3397,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('23'),
|
('23'),
|
||||||
('22'),
|
('22'),
|
||||||
('21'),
|
('21'),
|
||||||
|
('20241023004427'),
|
||||||
('20241022141247'),
|
('20241022141247'),
|
||||||
('20240913171951'),
|
('20240913171951'),
|
||||||
('20240912181413'),
|
('20240912181413'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue