-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11212 from demarches-simplifiees/fix_columns_migr…
…ation Opérateurs: ajoute de la doc sur les taches de mis a jour des id columns
- Loading branch information
Showing
8 changed files
with
135 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
app/tasks/maintenance/migrate_export_address_and_linked_columns_task.rb
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
app/tasks/maintenance/migrate_export_template_address_and_linked_columns_task.rb
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
app/tasks/maintenance/t20250115_refresh_columns_id_in_export_task.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# This task run over all exports to reload the columns and reserialize them using their current id | ||
# In order to be refreshed, the column must be unserialized so the method find_column in ColumnConcern must be adapted to work with the old and new id format | ||
# this task should be use with the task t20250115refreshColumnsIdInExportTask, t20250115refreshColumnsIdInExportTemplateTask, t20250115refreshColumnsIdInProcedurePresentationTask | ||
module Maintenance | ||
class T20250115RefreshColumnsIdInExportTask < MaintenanceTasks::Task | ||
include RunnableOnDeployConcern | ||
|
||
run_on_first_deploy | ||
|
||
def collection | ||
Export.all | ||
end | ||
|
||
def process(export) | ||
# by using the `will_change!` method, we ensure that the column will be saved | ||
# and thus the address and linked columns id will be migrated to the new format | ||
export.filtered_columns_will_change! | ||
export.sorted_column_will_change! | ||
|
||
export.save(validate: false) | ||
|
||
# a column can be not found for various reasons (deleted tdc, changed type, etc) | ||
# in this case we just ignore the error and continue | ||
rescue ActiveRecord::RecordNotFound | ||
end | ||
end | ||
end |
28 changes: 28 additions & 0 deletions
28
app/tasks/maintenance/t20250115_refresh_columns_id_in_export_template_task.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
# This task run over all export_templates to reload the columns and reserialize them using their current id | ||
# In order to be refreshed, the column must be unserialized so the method find_column in ColumnConcern must be adapted to work with the old and new id format | ||
# this task should be use with the task t20250115refreshColumnsIdInExportTask, t20250115refreshColumnsIdInExportTemplateTask, t20250115refreshColumnsIdInProcedurePresentationTask | ||
module Maintenance | ||
class T20250115RefreshColumnsIdInExportTemplateTask < MaintenanceTasks::Task | ||
include RunnableOnDeployConcern | ||
|
||
run_on_first_deploy | ||
|
||
def collection | ||
ExportTemplate.all | ||
end | ||
|
||
def process(export_template) | ||
# by using the `will_change!` method, we ensure that the column will be saved | ||
# and thus the address and linked columns id will be migrated to the new format | ||
export_template.exported_columns_will_change! | ||
|
||
export_template.save(validate: false) | ||
|
||
# a column can be not found for various reasons (deleted tdc, changed type, etc) | ||
# in this case we just ignore the error and continue | ||
rescue ActiveRecord::RecordNotFound | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters