add stable_id and stream

This commit is contained in:
Paul Chavard 2024-03-15 14:56:46 +01:00
parent 72077952e7
commit 8abe3fce79
6 changed files with 36 additions and 7 deletions

View file

@ -221,7 +221,7 @@ class Champ < ApplicationRecord
end
def clone(fork = false)
champ_attributes = [:parent_id, :private, :row_id, :type, :type_de_champ_id]
champ_attributes = [:parent_id, :private, :row_id, :type, :type_de_champ_id, :stable_id, :stream]
value_attributes = fork || !private? ? [:value, :value_json, :data, :external_id] : []
relationships = fork || !private? ? [:etablissement, :geo_areas] : []

View file

@ -250,7 +250,9 @@ class TypeDeChamp < ApplicationRecord
def params_for_champ
{
private: private?,
type: "Champs::#{type_champ.classify}Champ"
type: "Champs::#{type_champ.classify}Champ",
stable_id:,
stream: 'main'
}
end

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
module Maintenance
class FillChampsStableIdTask < MaintenanceTasks::Task
def collection
Champ.includes(:type_de_champ)
end
def process(champ)
champ.update_columns(stable_id: champ.stable_id, stream: 'main')
end
end
end