Skip to content

Commit 2946287

Browse files
committed
fixed migrations to either move single content type to table or bring the latest from table
1 parent 144d54e commit 2946287

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
(ns source.migrations.003-bundle-content-types
22
(:require [source.db.master]
3-
[source.db.tables :as tables]))
3+
[source.db.tables :as tables]
4+
[source.services.interface :as services]))
45

56
(defn run-up! [context]
6-
(let [ds-master (:db-master context)]
7+
(let [ds-master (:db-master context)
8+
bundles (services/bundles ds-master)]
9+
710
(tables/create-tables!
811
ds-master
912
:source.db.master
10-
[:bundle-content-types])))
13+
[:bundle-content-types])
14+
15+
(run! (fn [{:keys [id content-type-id]}]
16+
(when (some? content-type-id)
17+
(services/insert-bundle-content-types! ds-master {:data {:bundle-id id
18+
:content-type-id content-type-id}})))
19+
bundles)))
1120

1221
(defn run-down! [context]
13-
(let [ds-master (:db-master context)]
22+
(let [ds-master (:db-master context)
23+
bundle-content-types (services/bundles ds-master)]
24+
25+
(run! (fn [{:keys [bundle-id content-type-id]}]
26+
(services/update-bundle! ds-master {:id bundle-id
27+
:data {:content-type-id content-type-id}}))
28+
bundle-content-types)
29+
1430
(tables/drop-table! ds-master :bundle-content-types)))

0 commit comments

Comments
 (0)