forked from yesodweb/persistent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMigrationTest.hs
41 lines (36 loc) · 1.04 KB
/
MigrationTest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE QuasiQuotes, TemplateHaskell, CPP, GADTs, TypeFamilies, OverloadedStrings, FlexibleContexts, EmptyDataDecls #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module MigrationTest where
#ifndef WITH_MONGODB
import Database.Persist.Sqlite
#endif
import Database.Persist.TH
import qualified Data.Text as T
import Init
#ifdef WITH_MONGODB
mkPersist persistSettings [persistUpperCase|
#else
share [mkPersist sqlSettings, mkMigrate "migrationMigrate", mkDeleteCascade sqlSettings] [persistLowerCase|
#endif
Target
field1 Int
field2 T.Text
UniqueTarget field1 field2
deriving Eq Show
Source
field3 Int
field4 TargetId
|]
#ifndef WITH_MONGODB
specs :: Spec
specs = describe "Migration" $ do
it "is idempotent" $ db $ do
again <- getMigration migrationMigrate
liftIO $ again @?= []
it "really is idempotent" $ db $ do
runMigration migrationMigrate
again <- getMigration migrationMigrate
liftIO $ again @?= []
#endif