Merge pull request #11173 from opf/fix/journal-id-deletion

Do not delete data journal id, but journal_id reference
pull/11175/head
ulferts 2 years ago committed by GitHub
commit 4d827dfb04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      app/services/journals/create_service.rb

@ -177,22 +177,25 @@ module Journals
def cleanup_predecessor_data(predecessor)
cleanup_predecessor(predecessor,
data_table_name,
:id)
:id,
:data_id)
end
def cleanup_predecessor_attachable(predecessor)
cleanup_predecessor(predecessor,
'attachable_journals',
:journal_id)
:journal_id,
:id)
end
def cleanup_predecessor_customizable(predecessor)
cleanup_predecessor(predecessor,
'customizable_journals',
:journal_id)
:journal_id,
:id)
end
def cleanup_predecessor(predecessor, table_name, column)
def cleanup_predecessor(predecessor, table_name, column, referenced_id)
return "SELECT 1" unless predecessor
sql = <<~SQL
@ -204,7 +207,7 @@ module Journals
SQL
sanitize sql,
column => predecessor.id
column => predecessor.send(referenced_id)
end
def update_or_insert_journal_sql(predecessor, notes)

Loading…
Cancel
Save