From 6d53452ebc24287a72eedb9a2cc3f9e21c55362c Mon Sep 17 00:00:00 2001
From: Jonathan Bradley <jcb@pikum.xyz>
Date: Mon, 13 Oct 2025 15:27:59 -0400
Subject: pke-at: second-pass sql storage

---
 src/sql/section_upsert.sql | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

(limited to 'src/sql/section_upsert.sql')

diff --git a/src/sql/section_upsert.sql b/src/sql/section_upsert.sql
index 4ca1025..659d66a 100644
--- a/src/sql/section_upsert.sql
+++ b/src/sql/section_upsert.sql
@@ -1,10 +1,9 @@
-INSERT INTO [at_section] (uuid,section_type,sequence,beats_per_bar,bar_count)
-	VALUES('%s','%s','%s','%s','%s')
-		ON CONFLICT(uuid) DO UPDATE SET
+INSERT INTO [at_section] (uuid,sequence,section_type,beats_per_bar,bar_count)
+	VALUES('%s','%i','%u','%u','%u')
+		ON CONFLICT(song_uuid,sequence) DO UPDATE SET
 			section_type=excluded.section_type
-			,sequence=excluded.sequence
 			,beats_per_bar=excluded.beats_per_bar
 			,bar_count=excluded.bar_count
 			,is_deleted=0
 			,modification_dt=unixepoch('now')
-		WHERE uuid=excluded.uuid;
+		WHERE song_uuid=excluded.uuid AND sequence=excluded.sequence;
-- 
cgit v1.2.3

