module Database.Persist.Migration
( hasMigration
, checkMigration
, module Database.Persist.Migration.Backend
, module Database.Persist.Migration.Core
, module Database.Persist.Migration.Operation
, module Database.Persist.Migration.Operation.Types
, module Database.Persist.Migration.Utils.Sql
, PersistValue(..)
, SqlType(..)
) where
import Control.Monad (unless)
import Control.Monad.IO.Class (MonadIO)
import qualified Data.Text as Text
import Database.Persist (PersistValue(..), SqlType(..))
import Database.Persist.Migration.Backend
import Database.Persist.Migration.Core hiding (getMigration, runMigration)
import Database.Persist.Migration.Operation
import Database.Persist.Migration.Operation.Types
import Database.Persist.Migration.Utils.Sql
import qualified Database.Persist.Sql as Persistent
hasMigration :: MonadIO m => Persistent.Migration -> Persistent.SqlPersistT m Bool
hasMigration = fmap (not . null) . Persistent.showMigration
checkMigration :: MonadIO m => Persistent.Migration -> Persistent.SqlPersistT m ()
checkMigration migration = do
migrationText <- Persistent.showMigration migration
unless (null migrationText) $ fail $
unlines $ "More migrations detected:" : bullets migrationText
where
bullets = map ((" * " ++ ) . Text.unpack)