demarches-normaliennes/app/tasks/maintenance/fill_champs_stable_id_task.rb
2024-03-19 14:25:36 +01:00

20 lines
461 B
Ruby

# frozen_string_literal: true
module Maintenance
class FillChampsStableIdTask < MaintenanceTasks::Task
def collection
Champ.all
end
def process(champ)
if !champ.attribute_present?(:stable_id)
champ.update_columns(stable_id: champ.stable_id, stream: 'main')
end
end
def count
sql = "SELECT reltuples FROM pg_class WHERE relname = 'champs';"
Champ.connection.select_value(sql).to_i
end
end
end