Skip to content

Commit

Permalink
Always recreate views when starting the pool worker.
Browse files Browse the repository at this point in the history
This makes it possible to change the definitions of views as required.
  • Loading branch information
jonathanknowles committed Sep 10, 2020
1 parent a41adbc commit 7aabf90
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/core/src/Cardano/Pool/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,18 @@ data DatabaseView = DatabaseView
--
createView :: Sqlite.Connection -> DatabaseView -> IO ()
createView conn (DatabaseView name definition) = do
query <- Sqlite.prepare conn queryString
Sqlite.step query *> Sqlite.finalize query
deleteQuery <- Sqlite.prepare conn deleteQueryString
Sqlite.step deleteQuery *> Sqlite.finalize deleteQuery
createQuery <- Sqlite.prepare conn createQueryString
Sqlite.step createQuery *> Sqlite.finalize createQuery
where
queryString = T.unlines
[ "CREATE VIEW IF NOT EXISTS"
deleteQueryString = T.unlines
[ "DROP VIEW IF EXISTS"
, name
, ";"
]
createQueryString = T.unlines
[ "CREATE VIEW"
, name
, "AS"
, definition
Expand Down

0 comments on commit 7aabf90

Please sign in to comment.