module Database.Persist.Migration
(
Version
, OperationPath
, (~>)
, Operation(..)
, Migration
, MigrateBackend(..)
, Migrateable(..)
, MigrateSettings(..)
, defaultSettings
, hasMigration
, checkMigration
, CreateTable(..)
, DropTable(..)
, AddColumn(..)
, DropColumn(..)
, RawOperation(..)
, NoOp(..)
, ColumnIdentifier
, dotted
, Column(..)
, ColumnProp(..)
, TableConstraint(..)
) where
import Control.Monad (unless)
import Control.Monad.IO.Class (MonadIO)
import qualified Data.Text as Text
import Database.Persist.Migration.Internal
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)