Skip to content
Snippets Groups Projects
Unverified Commit d8054f18 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Initialize the schema in a transaction

It's probably not strictly necessary but it's sort of nice.
parent 967e34f1
Branches
No related tags found
1 merge request!61Fix intermittent "Database is locked" errors
......@@ -337,6 +337,7 @@ sqlite path =
dbConn <- Sqlite.open (unpack path)
let exec = Sqlite.execute_ dbConn
exec "PRAGMA foreign_keys = ON"
Sqlite.withExclusiveTransaction dbConn $ do
exec "CREATE TABLE IF NOT EXISTS vouchers (id INTEGER PRIMARY KEY, name TEXT UNIQUE)"
exec "CREATE TABLE IF NOT EXISTS redeemed (id INTEGER PRIMARY KEY, voucher_id INTEGER, counter INTEGER, fingerprint TEXT, FOREIGN KEY (voucher_id) REFERENCES vouchers(id))"
return dbConn
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment