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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user