Skip to content
Permalink
Browse files

Sqlite: add on delete cascade constraints

  • Loading branch information...
rvl committed May 16, 2019
1 parent 449606c commit 91b630f7493fa11f04250b469b6f54988f15a02b
Showing with 10 additions and 9 deletions.
  1. +4 −9 lib/core/src/Cardano/Wallet/DB/Sqlite.hs
  2. +6 −0 lib/core/src/Cardano/Wallet/DB/SqliteTypes.hs
@@ -32,7 +32,7 @@ import Cardano.Wallet.DB
, PrimaryKey (..)
)
import Cardano.Wallet.DB.SqliteTypes
( AddressScheme (..), TxId (..) )
( AddressScheme (..), TxId (..), sqlSettings' )
import Cardano.Wallet.Primitive.AddressDerivation
( Depth (..), Key, deserializeKey, getKey, serializeKey )
import Cardano.Wallet.Primitive.AddressDiscovery
@@ -97,13 +97,7 @@ import Database.Persist.Sql
import Database.Persist.Sqlite
( SqlBackend, SqlPersistM, wrapConnection )
import Database.Persist.TH
( MkPersistSettings (..)
, mkMigrate
, mkPersist
, persistLowerCase
, share
, sqlSettings
)
( mkDeleteCascade, mkMigrate, mkPersist, persistLowerCase, share )
import GHC.Generics
( Generic )
import Numeric.Natural
@@ -122,7 +116,8 @@ import qualified Data.Text as T
import qualified Database.Sqlite as Sqlite

share
[ mkPersist sqlSettings { mpsPrefixFields = False }
[ mkPersist sqlSettings'
, mkDeleteCascade sqlSettings'
, mkMigrate "migrateAll"
]
[persistLowerCase|
@@ -53,6 +53,8 @@ import Data.Word
( Word64, Word8 )
import Database.Persist.Sqlite
( PersistField (..), PersistFieldSql (..), PersistValue )
import Database.Persist.TH
( MkPersistSettings (..), sqlSettings )
import GHC.Generics
( Generic )
import Web.HttpApiData
@@ -62,6 +64,10 @@ import Web.PathPieces

import qualified Data.Text as T

----------------------------------------------------------------------------

sqlSettings' :: MkPersistSettings
sqlSettings' = sqlSettings { mpsPrefixFields = False }

----------------------------------------------------------------------------
-- Helper functions

0 comments on commit 91b630f

Please sign in to comment.
You can’t perform that action at this time.