diff --git a/lib/unison-sqlite/src/Unison/Sqlite/Connection.hs b/lib/unison-sqlite/src/Unison/Sqlite/Connection.hs index 3fa2c864b..f46917ddc 100644 --- a/lib/unison-sqlite/src/Unison/Sqlite/Connection.hs +++ b/lib/unison-sqlite/src/Unison/Sqlite/Connection.hs @@ -104,7 +104,6 @@ openConnection name file = do _ -> "file:" <> file <> "?mode=ro" conn0 <- Sqlite.open sqliteURI `catch` rethrowAsSqliteConnectException name file let conn = Connection {conn = conn0, file, name} - execute conn [Sql.sql| PRAGMA journal_mode = wal |] execute conn [Sql.sql| PRAGMA foreign_keys = ON |] execute conn [Sql.sql| PRAGMA busy_timeout = 60000 |] pure conn diff --git a/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs b/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs index 59250dc25..4417595fe 100644 --- a/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs +++ b/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs @@ -783,3 +783,6 @@ copyCodebase src dest = liftIO $ do createDirectoryIfMissing True (makeCodebaseDirPath dest) withConnection ("copy-from:" <> src) src $ \srcConn -> do Sqlite.vacuumInto srcConn (makeCodebasePath dest) + -- We need to reset the journal mode because vacuum-into clears it. + withConnection ("copy-to:" <> dest) dest $ \destConn -> do + Sqlite.trySetJournalMode destConn Sqlite.JournalMode'WAL diff --git a/parser-typechecker/src/Unison/Codebase/SqliteCodebase/Migrations.hs b/parser-typechecker/src/Unison/Codebase/SqliteCodebase/Migrations.hs index 0911fd6b3..2bfa90545 100644 --- a/parser-typechecker/src/Unison/Codebase/SqliteCodebase/Migrations.hs +++ b/parser-typechecker/src/Unison/Codebase/SqliteCodebase/Migrations.hs @@ -192,5 +192,8 @@ backupCodebaseIfNecessary backupStrategy localOrRemote conn currentSchemaVersion | otherwise -> do backupPath <- getPOSIXTime <&> (\t -> root backupCodebasePath currentSchemaVersion t) Sqlite.vacuumInto conn backupPath + -- vacuum-into clears the journal mode, so we need to set it again. + Sqlite.withConnection "backup" backupPath \backupConn -> do + Sqlite.trySetJournalMode backupConn Sqlite.JournalMode'WAL putStrLn ("📋 I backed up your codebase to " ++ (root backupPath)) putStrLn "⚠️ Please close all other ucm processes and wait for the migration to complete before interacting with your codebase."