From bd753dbe477c2fabc45160cd067038cedf7d52fc Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Mon, 29 Mar 2021 19:27:05 +0400 Subject: [PATCH] agent sqlite: enable FKs in *all* db connections (#75) --- src/Simplex/Messaging/Agent/Store/SQLite.hs | 1 + src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Simplex/Messaging/Agent/Store/SQLite.hs b/src/Simplex/Messaging/Agent/Store/SQLite.hs index ad72ca047..0b83bbd77 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite.hs @@ -72,6 +72,7 @@ createSQLiteStore dbFilePath = do connectSQLiteStore :: MonadUnliftIO m => FilePath -> m SQLiteStore connectSQLiteStore dbFilePath = do dbConn <- liftIO $ DB.open dbFilePath + liftIO $ DB.execute_ dbConn "PRAGMA foreign_keys = ON;" return SQLiteStore {dbFilePath, dbConn} instance (MonadUnliftIO m, MonadError StoreError m) => MonadAgentStore SQLiteStore m where diff --git a/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs b/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs index 7ca9a5f85..12d886a4e 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite/Schema.hs @@ -10,8 +10,7 @@ createSchema :: Connection -> IO () createSchema conn = mapM_ (execute_ conn) - [ enableFKs, - servers, + [ servers, rcvQueues, sndQueues, connections, @@ -20,9 +19,6 @@ createSchema conn = sndMessages ] -enableFKs :: Query -enableFKs = "PRAGMA foreign_keys = ON;" - -- port is either a port number or a service name, see Network.Socket.Info.ServiceName servers :: Query servers =