From 893f19fa5e90331dd40d60ca366f4407c4aeecbf Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 21 Feb 2025 14:24:07 +0100 Subject: [PATCH 1/2] :sparkles: Remove automatic cascade on file_change table fk constraint --- backend/src/app/migrations.clj | 5 ++++- .../src/app/migrations/sql/0139-mod-file-change-table.sql | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 backend/src/app/migrations/sql/0139-mod-file-change-table.sql diff --git a/backend/src/app/migrations.clj b/backend/src/app/migrations.clj index f30075f94f..795a9bea5c 100644 --- a/backend/src/app/migrations.clj +++ b/backend/src/app/migrations.clj @@ -435,7 +435,10 @@ :fn (mg/resource "app/migrations/sql/0137-add-file-migration-table.sql")} {:name "0138-mod-file-data-fragment-table.sql" - :fn (mg/resource "app/migrations/sql/0138-mod-file-data-fragment-table.sql")}]) + :fn (mg/resource "app/migrations/sql/0138-mod-file-data-fragment-table.sql")} + + {:name "0139-mod-file-change-table.sql" + :fn (mg/resource "app/migrations/sql/0139-mod-file-change-table.sql")}]) (defn apply-migrations! [pool name migrations] diff --git a/backend/src/app/migrations/sql/0139-mod-file-change-table.sql b/backend/src/app/migrations/sql/0139-mod-file-change-table.sql new file mode 100644 index 0000000000..0b8171325c --- /dev/null +++ b/backend/src/app/migrations/sql/0139-mod-file-change-table.sql @@ -0,0 +1,5 @@ +ALTER TABLE file_change + DROP CONSTRAINT file_change_file_id_fkey, + DROP CONSTRAINT file_change_profile_id_fkey, + ADD FOREIGN KEY (file_id) REFERENCES file(id) DEFERRABLE, + ADD FOREIGN KEY (profile_id) REFERENCES profile(id) ON DELETE SET NULL DEFERRABLE; From d2c800fc0f415796683a34de656b150f18cdee54 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 21 Feb 2025 14:24:18 +0100 Subject: [PATCH 2/2] :bug: Add missing handling of file_change on delete-object task --- backend/src/app/tasks/delete_object.clj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/app/tasks/delete_object.clj b/backend/src/app/tasks/delete_object.clj index b9939c8be0..29370e61e0 100644 --- a/backend/src/app/tasks/delete_object.clj +++ b/backend/src/app/tasks/delete_object.clj @@ -40,6 +40,11 @@ :file-id id :cause cause)))) + ;; Mark file change to be deleted + (db/update! conn :file-change + {:deleted-at deleted-at} + {:file-id id}) + ;; Mark file media objects to be deleted (db/update! conn :file-media-object {:deleted-at deleted-at}