Skip to content

Commit 0b11700

Browse files
austbZak-Kent
authored andcommitted
(PDB-4832) Add schema-diff check for migration 76
Add a schema diff check for migration 76 when the index has not been applied by migration 74 (which will be the case for anyone running a version of pdb between 6.10.0 and 6.11.2.
1 parent 0ef1f1a commit 0b11700

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/puppetlabs/puppetdb/scf/migrate_partitioning_test.clj

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,3 +1277,40 @@
12771277
:same nil}]))
12781278
dates))}
12791279
(diff-schema-maps before-migration (schema-info-map *db*))))))
1280+
1281+
(deftest migration-76-schema-diff
1282+
(clear-db-for-testing!)
1283+
;; don't add the idx_reports_id index when fast forwarding past migration 74
1284+
(binding [partitioning/add-report-id-idx? false]
1285+
(fast-forward-to-migration! 75))
1286+
1287+
(let [before-migration (schema-info-map *db*)
1288+
today (ZonedDateTime/now (ZoneId/of "UTC"))
1289+
days-range (range -4 4)
1290+
dates (map #(.plusDays today %) days-range)
1291+
part-names (map #(str/lower-case (partitioning/date-suffix %)) dates)]
1292+
(apply-migration-for-testing! 76)
1293+
1294+
(is (= {:index-diff (into
1295+
[]
1296+
cat
1297+
(map
1298+
(fn [part-name]
1299+
(let [table-name (str "reports_" part-name)]
1300+
[{:left-only nil
1301+
:right-only
1302+
{:schema "public"
1303+
:table table-name
1304+
:index (str "idx_reports_id_" part-name)
1305+
:index_keys ["id"]
1306+
:type "btree"
1307+
:unique? true
1308+
:functional? false
1309+
:is_partial false
1310+
:primary? false
1311+
:user "pdb_test"}
1312+
:same nil}]))
1313+
part-names))
1314+
:table-diff nil
1315+
:constraint-diff nil}
1316+
(diff-schema-maps before-migration (schema-info-map *db*))))))

0 commit comments

Comments
 (0)