Skip to content

Commit 5d24070

Browse files
anjastrunkmbuechse
authored andcommitted
Fix empty db schema
Signed-off-by: Anja Strunk <[email protected]>
1 parent a6e04a0 commit 5d24070

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

compliance-monitor/sql.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,13 @@ def db_get_schema_version(cur: cursor):
169169

170170

171171
def db_set_schema_version(cur: cursor, version: str):
172-
cur.execute('''
173-
UPDATE meta SET value = %s WHERE key = %s
174-
;''', (version, SCHEMA_VERSION_KEY))
172+
cur.execute('''
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)