This repository was archived by the owner on Sep 20, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-15
lines changed
src/Database/PostgreSQL/Simple Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -114,14 +114,8 @@ executeDirectoryMigration :: Connection -> Bool -> FilePath -> IO (MigrationResu
114
114
executeDirectoryMigration con verbose dir =
115
115
scriptsInDirectory dir >>= go
116
116
where
117
- go [] = return MigrationSuccess
118
- go (f: fs) = do
119
- r <- executeMigration con verbose f =<< BS. readFile (dir ++ " /" ++ f)
120
- case r of
121
- MigrationError _ ->
122
- return r
123
- MigrationSuccess ->
124
- go fs
117
+ go fs = sequenceMigrations (executeMigrationFile <$> fs)
118
+ executeMigrationFile f = executeMigration con verbose f =<< BS. readFile (dir ++ " /" ++ f)
125
119
126
120
-- | Lists all files in the given 'FilePath' 'dir' in alphabetical order.
127
121
scriptsInDirectory :: FilePath -> IO [String ]
@@ -202,13 +196,8 @@ executeValidation con verbose cmd = case cmd of
202
196
when verbose $ putStrLn $ " Checksum mismatch:\t " ++ name
203
197
return (MigrationError $ " Checksum mismatch: " ++ name)
204
198
205
- goScripts _ [] = return MigrationSuccess
206
- goScripts path (x: xs) =
207
- (validate x =<< BS. readFile (path ++ " /" ++ x)) >>= \ case
208
- e@ (MigrationError _) ->
209
- return e
210
- MigrationSuccess ->
211
- goScripts path xs
199
+ goScripts path xs = sequenceMigrations (goScript path <$> xs)
200
+ goScript path x = validate x =<< BS. readFile (path ++ " /" ++ x)
212
201
213
202
-- | Checks the status of the script with the given name 'name'.
214
203
-- If the script has already been executed, the checksum of the script
You can’t perform that action at this time.
0 commit comments