diff --git a/backend/src/app/migrations.clj b/backend/src/app/migrations.clj index 787d34450..ecaeae7c3 100644 --- a/backend/src/app/migrations.clj +++ b/backend/src/app/migrations.clj @@ -324,6 +324,9 @@ {:name "0104-mod-file-thumbnail-table" :fn (mg/resource "app/migrations/sql/0104-mod-file-thumbnail-table.sql")} + {:name "0105-mod-file-change-table" + :fn (mg/resource "app/migrations/sql/0105-mod-file-change-table.sql")} + ]) (defn apply-migrations! diff --git a/backend/src/app/migrations/sql/0105-mod-file-change-table.sql b/backend/src/app/migrations/sql/0105-mod-file-change-table.sql new file mode 100644 index 000000000..d8385df9e --- /dev/null +++ b/backend/src/app/migrations/sql/0105-mod-file-change-table.sql @@ -0,0 +1,9 @@ +ALTER TABLE file_change + ADD COLUMN label text NULL; + +ALTER TABLE file_change + ALTER COLUMN label SET STORAGE external; + +CREATE INDEX file_change__label__idx + ON file_change (file_id, label) + WHERE label is not null; diff --git a/backend/src/app/tasks/file_xlog_gc.clj b/backend/src/app/tasks/file_xlog_gc.clj index 5ee2e1bbc..c88f42a84 100644 --- a/backend/src/app/tasks/file_xlog_gc.clj +++ b/backend/src/app/tasks/file_xlog_gc.clj @@ -17,7 +17,8 @@ (def ^:private sql:delete-files-xlog "delete from file_change - where created_at < now() - ?::interval") + where created_at < now() - ?::interval + and label is NULL") (defmethod ig/pre-init-spec ::handler [_] (s/keys :req [::db/pool]))