Skip existing prices on insert and add unique index on (time_dk, price_area)

Changed upsert to INSERT ON CONFLICT DO NOTHING so existing prices are
never overwritten. Added unique index on (time_dk, price_area) to enforce
no duplicate quarter-hour entries per area.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 13:14:28 +01:00
co-authored by Claude Opus 4.6
parent 9554e511ad
commit 97a95684cf
4 changed files with 7 additions and 8 deletions
@@ -57,10 +57,10 @@
(.replace ^String s "T" " "))))
(defn save-records!
"Upsert price records into the database."
"Insert price records into the database, skipping existing ones."
[query-fn records]
(doseq [rec records]
(query-fn :upsert-price!
(query-fn :insert-price!
{:time-utc (parse-timestamp (:TimeUTC rec))
:time-dk (parse-timestamp (:TimeDK rec))
:price-area (:PriceArea rec)