scinote-web/db/migrate/20241001163211_add_counter_cache_repository_row.rb

13 lines
357 B
Ruby

# frozen_string_literal: true
class AddCounterCacheRepositoryRow < ActiveRecord::Migration[7.0]
def change
change_table :repositories, bulk: true do |t|
t.integer :repository_rows_count, default: 0, null: false
end
Repository.find_each do |repository|
Repository.reset_counters(repository.id, :repository_rows)
end
end
end