Merge pull request #10299 from demarches-simplifiees/fix_cron_discarded_procedures_deletion_job

Tech: corrige le job de suppression des procédures cachées sans dossiers
This commit is contained in:
Paul Chavard 2024-04-11 12:55:54 +00:00 committed by GitHub
commit 91a75a313e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 6 deletions

View file

@ -770,7 +770,11 @@ class Procedure < ApplicationRecord
end
def self.purge_discarded
discarded_expired.find_each(&:purge_discarded)
discarded_expired.find_each do |p|
p.purge_discarded
rescue StandardError => e
Sentry.capture_exception(e, extra: { procedure_id: p.id })
end
end
def restore(author)

View file

@ -1,5 +1,4 @@
class ProcedureRevision < ApplicationRecord
self.ignored_columns += [:attestation_template_id]
self.implicit_order_column = :created_at
belongs_to :procedure, -> { with_discarded }, inverse_of: :revisions, optional: false
belongs_to :dossier_submitted_message, inverse_of: :revisions, optional: true, dependent: :destroy

View file

@ -0,0 +1,7 @@
class DropAttestationTemplateIdFromProcedureRevisionsTable < ActiveRecord::Migration[7.0]
def up
safety_assured do
remove_column :procedure_revisions, :attestation_template_id
end
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2024_04_10_193614) do
ActiveRecord::Schema[7.0].define(version: 2024_04_11_091345) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_buffercache"
enable_extension "pg_stat_statements"
@ -853,13 +853,11 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_10_193614) do
end
create_table "procedure_revisions", force: :cascade do |t|
t.bigint "attestation_template_id"
t.datetime "created_at", precision: nil, null: false
t.bigint "dossier_submitted_message_id"
t.bigint "procedure_id", null: false
t.datetime "published_at", precision: nil
t.datetime "updated_at", precision: nil, null: false
t.index ["attestation_template_id"], name: "index_procedure_revisions_on_attestation_template_id"
t.index ["dossier_submitted_message_id"], name: "index_procedure_revisions_on_dossier_submitted_message_id"
t.index ["procedure_id"], name: "index_procedure_revisions_on_procedure_id"
end
@ -1253,7 +1251,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_10_193614) do
add_foreign_key "procedure_revision_types_de_champ", "procedure_revision_types_de_champ", column: "parent_id"
add_foreign_key "procedure_revision_types_de_champ", "procedure_revisions", column: "revision_id"
add_foreign_key "procedure_revision_types_de_champ", "types_de_champ"
add_foreign_key "procedure_revisions", "attestation_templates"
add_foreign_key "procedure_revisions", "dossier_submitted_messages"
add_foreign_key "procedure_revisions", "procedures"
add_foreign_key "procedures", "groupe_instructeurs", column: "defaut_groupe_instructeur_id"