From a4192ce8355f0931b5cdf950fdabdd6a6afbee67 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 13 Oct 2025 18:22:40 +0200 Subject: [PATCH] :bug: Fix incorrect file data migration from db to legacy-db --- backend/src/app/binfile/common.clj | 2 +- backend/src/app/features/fdata.clj | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/backend/src/app/binfile/common.clj b/backend/src/app/binfile/common.clj index b4d7bafdcb..1781860c05 100644 --- a/backend/src/app/binfile/common.clj +++ b/backend/src/app/binfile/common.clj @@ -633,7 +633,7 @@ (dissoc :team-id) (dissoc :migrations))) -(defn file->file-data-params +(defn- file->file-data-params [{:keys [id] :as file} & {:as opts}] (let [created-at (or (:created-at file) (ct/now)) modified-at (or (:modified-at file) created-at)] diff --git a/backend/src/app/features/fdata.clj b/backend/src/app/features/fdata.clj index 6a4bebe243..16afb9fd1a 100644 --- a/backend/src/app/features/fdata.clj +++ b/backend/src/app/features/fdata.clj @@ -172,16 +172,24 @@ (= backend "legacy-db") (cond (= type "main") - (db/update! cfg :file - {:data data} - {:id file-id} - {::db/return-keys false}) + (do + (db/delete! cfg :file-data + {:id id :file-id file-id :type "main"} + {::db/return-keys false}) + (db/update! cfg :file + {:data data} + {:id file-id} + {::db/return-keys false})) (= type "snapshot") - (db/update! cfg :file-change - {:data data} - {:file-id file-id :id id} - {::db/return-keys false}) + (do + (db/delete! cfg :file-data + {:id id :file-id file-id :type "snapshot"} + {::db/return-keys false}) + (db/update! cfg :file-change + {:data data} + {:file-id file-id :id id} + {::db/return-keys false})) (= type "fragment") (upsert-in-database cfg