From f65518f865863ccc6fa66ce95374d8f462c7de45 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 23 Apr 2025 17:22:22 +0200 Subject: [PATCH 1/2] :bug: Fix incorrect migration application after binfile import --- backend/src/app/binfile/v3.clj | 10 +++++++++- common/src/app/common/files/migrations.cljc | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index 07e953d68d..07ba4618dd 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -15,6 +15,7 @@ [app.common.data.macros :as dm] [app.common.exceptions :as ex] [app.common.features :as cfeat] + [app.common.files.migrations :as-alias fmg] [app.common.json :as json] [app.common.logging :as l] [app.common.schema :as sm] @@ -745,7 +746,14 @@ (assoc :name file-name) (assoc :project-id project-id) (dissoc :options) - (bfc/process-file))] + (bfc/process-file) + + ;; NOTE: this is necessary because when we just + ;; creating a new file from imported artifact, + ;; there are no migrations registered on the + ;; database, so we need to persist all of them, not + ;; only the applied + (vary-meta dissoc ::fmg/migrated))] (bfm/register-pending-migrations! cfg file) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 1c08ad4743..4d9a80e235 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -37,8 +37,6 @@ #?(:cljs (l/set-level! :info)) (declare ^:private available-migrations) -(declare ^:private migration-up-index) -(declare ^:private migration-down-index) (def version cfd/version) From 80308ceafa24271303c93179522300dae0dadf99 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 23 Apr 2025 18:14:10 +0200 Subject: [PATCH 2/2] :bug: Make http cache aware of missing file data migrations --- backend/src/app/rpc/commands/files.clj | 3 +-- common/src/app/common/files/migrations.cljc | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 58a37810cc..117a432ab8 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -238,7 +238,6 @@ (db/update! conn :file {:data (blob/encode (:data file)) :version (:version file) - :modified-at (dt/now) :features (db/create-array conn "text" (:features file))} {:id id}) @@ -293,7 +292,7 @@ (defn get-file-etag [{:keys [::rpc/profile-id]} {:keys [modified-at revn vern permissions]}] - (str profile-id "/" revn "/" vern "/" + (str profile-id "/" revn "/" vern "/" (hash fmg/available-migrations) "/" (dt/format-instant modified-at :iso) "/" (uri/map->query-string permissions))) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 4d9a80e235..31d61e58c4 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -36,7 +36,7 @@ #?(:cljs (l/set-level! :info)) -(declare ^:private available-migrations) +(declare available-migrations) (def version cfd/version) @@ -48,7 +48,10 @@ [file] (or (nil? (:version file)) (not= cfd/version (:version file)) - (not= available-migrations (:migrations file)))) + (boolean + (->> (:migrations file #{}) + (set/difference available-migrations) + (not-empty))))) (def xf:map-name (map :name))