Skip to content

Commit

Permalink
Sqlite: Fix DB migrations on Windows
Browse files Browse the repository at this point in the history
The wallet failed with:

    NUL: openFile: does not exist (No such file or directory)

This is due to runMigrationSilent which uses the silently library:

http://hackage.haskell.org/package/silently-1.2.5.1/docs/src/System.IO.Silently.html#line-27

To fix, we swap runMigrationSilent with runMigrationQuiet (added in
persistent-2.10.2).
  • Loading branch information
rvl committed Nov 5, 2019
1 parent f75f38d commit 23875ba
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import Data.Maybe
import Data.Text
( Text )
import Database.Persist.Sql
( LogFunc, Migration, close', runMigrationSilent, runSqlConn )
( LogFunc, Migration, close', runMigrationQuiet, runSqlConn )
import Database.Persist.Sqlite
( SqlBackend, SqlPersistT, mkSqliteConnectionInfo, wrapConnectionInfo )
import Database.Sqlite
Expand Down Expand Up @@ -152,7 +152,7 @@ startSqliteBackend logConfig migrateAll trace fp = do
observe = bracketObserveIO logConfig traceQuery Debug "query"
let runQuery :: SqlPersistT IO a -> IO a
runQuery cmd = withMVar lock $ const $ observe $ runSqlConn cmd backend
migrations <- runQuery $ runMigrationSilent migrateAll
migrations <- runQuery $ runMigrationQuiet migrateAll
dbLog trace $ MsgMigrations (length migrations)
pure $ SqliteContext backend runQuery fp trace

Expand Down
4 changes: 2 additions & 2 deletions nix/.stack.nix/default.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nix/.stack.nix/persistent-sqlite.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions nix/.stack.nix/persistent-template.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions nix/.stack.nix/persistent.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ extra-deps:
- quickcheck-state-machine-0.6.0
- command-0.1.1

# persistent-sqlite with CASCADE DELETE support
# persistent-2.10.2 with CASCADE DELETE support for SQLite.
#
# See: https://github.com/input-output-hk/persistent/tree/cardano-wallet
- git: https://github.com/input-output-hk/persistent
commit: 79f2ece07eafae005a703c8eda1bd2420b5e07b5
commit: 107787ecc4c8a112375493cd66574f788f950fce
subdirs:
- persistent-sqlite
- persistent-template-2.7.2
- persistent-2.10.1
- persistent
- persistent-sqlite
- persistent-template

# cardano-crypto
- git: https://github.com/input-output-hk/cardano-crypto
Expand Down

0 comments on commit 23875ba

Please sign in to comment.