Skip to content
Snippets Groups Projects
Commit 038dc644 authored by Ramakrishnan Muthukrishnan's avatar Ramakrishnan Muthukrishnan
Browse files

enable foreign keys as sqlite default is to turn it off

parent 10187d9f
Branches
No related tags found
1 merge request!26Initial implementation of Persistence using sqlite
......@@ -153,6 +153,7 @@ insertVoucherAndFingerprint dbConn voucher fingerprint =
getDBConnection :: Text -> IO VoucherDatabaseState
getDBConnection name = do
dbConn <- Sqlite.open (unpack name)
Sqlite.execute_ dbConn "PRAGMA foreign_keys = ON"
Sqlite.execute_ dbConn "CREATE TABLE IF NOT EXISTS vouchers (id INTEGER PRIMARY KEY, name TEXT UNIQUE)"
Sqlite.execute_ dbConn "CREATE TABLE IF NOT EXISTS redeemed (id INTEGER PRIMARY KEY, voucher_id INTEGER, fingerprint TEXT, FOREIGN KEY (voucher_id) REFERENCES vouchers(id))"
return $ SQLiteDB dbConn
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment