Allow users to re-import the match list in the scouting app
We currently append the match list to the existing data in the table.
This patch makes it so the entries are replaced instead of duplicated.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I86fdc49f8f01861bd0b35da8042a28e03ee9c0f0
diff --git a/scouting/db/db.go b/scouting/db/db.go
index 99301f2..32646f1 100644
--- a/scouting/db/db.go
+++ b/scouting/db/db.go
@@ -204,7 +204,10 @@
"R1, R2, R3, B1, B2, B3) " +
"VALUES (" +
"$1, $2, $3, " +
- "$4, $5, $6, $7, $8, $9)")
+ "$4, $5, $6, $7, $8, $9) " +
+ "ON CONFLICT (MatchNumber, Round, CompLevel) DO UPDATE SET " +
+ "R1 = EXCLUDED.R1, R2 = EXCLUDED.R2, R3 = EXCLUDED.R3, " +
+ "B1 = EXCLUDED.B1, B2 = EXCLUDED.B2, B3 = EXCLUDED.B3")
if err != nil {
return errors.New(fmt.Sprint("Failed to prepare insertion into match database: ", err))
}