Merge pull request #4281 from Keirua/fix-rake-task
fix rake task for linking dossier and groupe_instructeur
This commit is contained in:
commit
d595ccb5a4
1 changed files with 4 additions and 3 deletions
|
@ -2,9 +2,10 @@ namespace :after_party do
|
|||
desc 'Deployment task: link_dossier_and_groupe_instructeur'
|
||||
task link_dossier_and_groupe_instructeur: :environment do
|
||||
sql = <<~SQL
|
||||
UPDATE dossiers SET groupe_instructeur_id = groupe_instructeurs.id
|
||||
FROM dossiers AS d1 INNER JOIN groupe_instructeurs ON groupe_instructeurs.procedure_id = d1.procedure_id
|
||||
WHERE dossiers.id = d1.id;
|
||||
UPDATE dossiers AS d1 SET groupe_instructeur_id = g.id
|
||||
FROM groupe_instructeurs AS g
|
||||
WHERE g.procedure_id = d1.procedure_id
|
||||
and d1.groupe_instructeur_id is null;
|
||||
SQL
|
||||
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
|
|
Loading…
Reference in a new issue