Skip to content

Commit 2602be8

Browse files
anjastrunkmbuechse
andauthored
Fix empty database schema (#910)
Signed-off-by: Anja Strunk <[email protected]> Signed-off-by: Matthias Büchse <[email protected]> Co-authored-by: Matthias Büchse <[email protected]>
1 parent a6e04a0 commit 2602be8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compliance-monitor/sql.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ def db_get_schema_version(cur: cursor):
170170

171171
def db_set_schema_version(cur: cursor, version: str):
172172
cur.execute('''
173-
UPDATE meta SET value = %s WHERE key = %s
174-
;''', (version, SCHEMA_VERSION_KEY))
173+
INSERT INTO meta (key, value)
174+
VALUES (%s, %s)
175+
ON CONFLICT (key)
176+
DO UPDATE
177+
SET value = EXCLUDED.value
178+
;''', (SCHEMA_VERSION_KEY, version))
175179

176180

177181
def db_upgrade_schema(conn: connection, cur: cursor):

0 commit comments

Comments
 (0)