diff --git a/src/Model/Migration.hs b/src/Model/Migration.hs index b8d960301..9897339e1 100644 --- a/src/Model/Migration.hs +++ b/src/Model/Migration.hs @@ -52,23 +52,28 @@ share [mkPersist sqlSettings, mkMigrate "migrateDBVersioning"] migrateAll :: (MonadLogger m, MonadBaseControl IO m, MonadIO m) => ReaderT SqlBackend m () migrateAll = do + $logDebugS "Migration" "Initial migration" mapM_ ($logInfoS "Migration") <=< runMigrationSilent $ do -- Manual migrations to go to InitialVersion below: migrateEnableExtension "citext" migrateDBVersioning - appliedMigrations <- map entityKey <$> selectList [] [] + $logDebugS "Migration" "Retrieve applied migrations" + appliedMigrations <- selectKeysList [] [] let missingMigrations = customMigrations `Map.withoutKeys` Set.fromList appliedMigrations doCustomMigration acc desc migration = acc <* do let AppliedMigrationKey appliedMigrationFrom appliedMigrationTo = desc + $logInfoS "Migration" [st|#{tshow appliedMigrationFrom} -> #{tshow appliedMigrationTo}|] appliedMigrationTime <- liftIO getCurrentTime _ <- migration insert AppliedMigration{..} -- Map.foldlWithKey traverses migrations in ascending order of AppliedMigrationKey + $logDebugS "Migration" "Apply missing migrations" Map.foldlWithKey doCustomMigration (return ()) missingMigrations + $logDebugS "Migration" "Persistent automatic migration" mapM_ ($logInfoS "Migration") =<< runMigrationSilent migrateAll' {-