mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
12 lines
360 B
Ruby
12 lines
360 B
Ruby
class RefreshAssignedSamplesCounters < ActiveRecord::Migration
|
|
def up
|
|
# Reset the counters for assigned samples
|
|
Sample.find_each do |sample|
|
|
sample.update(nr_of_modules_assigned_to: sample.my_modules.count)
|
|
end
|
|
|
|
MyModule.find_each do |my_module|
|
|
my_module.update(nr_of_assigned_samples: my_module.samples.count)
|
|
end
|
|
end
|
|
end
|