Skip to content

Commit bb0e21e

Browse files
committed
Fix soft-delete cascade for contact topic answers (#6837)
Add `acts_as_paranoid` to `ContactTopicAnswer` and add `deleted_at` column via migration to support soft deletion.
1 parent 851785c commit bb0e21e

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

app/models/contact_topic_answer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class ContactTopicAnswer < ApplicationRecord
22
belongs_to :case_contact
33
belongs_to :contact_topic, optional: true
4+
acts_as_paranoid
45

56
has_one :casa_case, through: :case_contact
67
has_one :casa_org, through: :case_contact
@@ -17,6 +18,7 @@ class ContactTopicAnswer < ApplicationRecord
1718
# Table name: contact_topic_answers
1819
#
1920
# id :bigint not null, primary key
21+
# deleted_at :datetime
2022
# selected :boolean default(FALSE), not null
2123
# value :text
2224
# created_at :datetime not null
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDeletedAtToContactTopicAnswers < ActiveRecord::Migration[7.2]
2+
def change
3+
add_column :contact_topic_answers, :deleted_at, :datetime
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.2].define(version: 2026_02_11_001655) do
13+
ActiveRecord::Schema[7.2].define(version: 2026_04_14_132818) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

@@ -259,6 +259,7 @@
259259
t.boolean "selected", default: false, null: false
260260
t.datetime "created_at", null: false
261261
t.datetime "updated_at", null: false
262+
t.datetime "deleted_at"
262263
t.index ["case_contact_id"], name: "index_contact_topic_answers_on_case_contact_id"
263264
end
264265

0 commit comments

Comments
 (0)