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 @@ -119,14 +119,8 @@ executeDirectoryMigration :: Connection -> Bool -> FilePath -> IO (MigrationResu
119
119
executeDirectoryMigration con verbose dir =
120
120
scriptsInDirectory dir >>= go
121
121
where
122
- go [] = return MigrationSuccess
123
- go (f: fs) = do
124
- r <- executeMigration con verbose f =<< BS. readFile (dir ++ " /" ++ f)
125
- case r of
126
- MigrationError _ ->
127
- return r
128
- MigrationSuccess ->
129
- go fs
122
+ go fs = sequenceMigrations (executeMigrationFile <$> fs)
123
+ executeMigrationFile f = executeMigration con verbose f =<< BS. readFile (dir ++ " /" ++ f)
130
124
131
125
-- | Lists all files in the given 'FilePath' 'dir' in alphabetical order.
132
126
scriptsInDirectory :: FilePath -> IO [String ]
@@ -207,13 +201,8 @@ executeValidation con verbose cmd = case cmd of
207
201
when verbose $ putStrLn $ " Checksum mismatch:\t " ++ name
208
202
return (MigrationError $ " Checksum mismatch: " ++ name)
209
203
210
- goScripts _ [] = return MigrationSuccess
211
- goScripts path (x: xs) =
212
- (validate x =<< BS. readFile (path ++ " /" ++ x)) >>= \ case
213
- e@ (MigrationError _) ->
214
- return e
215
- MigrationSuccess ->
216
- goScripts path xs
204
+ goScripts path xs = sequenceMigrations (goScript path <$> xs)
205
+ goScript path x = validate x =<< BS. readFile (path ++ " /" ++ x)
217
206
218
207
-- | Checks the status of the script with the given name 'name'.
219
208
-- If the script has already been executed, the checksum of the script
You can’t perform that action at this time.
0 commit comments