| Maintainer | Brandon Chinn <brandonchinn178@gmail.com> |
|---|---|
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.Persist.Migration
Contents
Description
Defines a migration framework for the persistent library.
Synopsis
- hasMigration :: MonadIO m => Migration -> SqlPersistT m Bool
- checkMigration :: MonadIO m => Migration -> SqlPersistT m ()
- module Database.Persist.Migration.Backend
- newtype MigrateSettings = MigrateSettings {
- versionToLabel :: Version -> Maybe String
- defaultSettings :: MigrateSettings
- validateMigration :: Migration -> Either String ()
- module Database.Persist.Migration.Operation
- module Database.Persist.Migration.Operation.Types
- module Database.Persist.Migration.Utils.Sql
- data PersistValue
- = PersistText Text
- | PersistByteString ByteString
- | PersistInt64 Int64
- | PersistDouble Double
- | PersistRational Rational
- | PersistBool Bool
- | PersistDay Day
- | PersistTimeOfDay TimeOfDay
- | PersistUTCTime UTCTime
- | PersistNull
- | PersistList [PersistValue]
- | PersistMap [(Text, PersistValue)]
- | PersistObjectId ByteString
- | PersistDbSpecific ByteString
- data SqlType
Documentation
hasMigration :: MonadIO m => Migration -> SqlPersistT m Bool Source #
True if the persistent library detects more migrations unaccounted for.
checkMigration :: MonadIO m => Migration -> SqlPersistT m () Source #
Fails if the persistent library detects more migrations unaccounted for.
Re-exports
newtype MigrateSettings Source #
Settings to customize migration steps.
Constructors
| MigrateSettings | |
Fields
| |
defaultSettings :: MigrateSettings Source #
Default migration settings.
data PersistValue #
A raw value which can be stored in any backend and can be marshalled to
and from a PersistField.
Constructors
| PersistText Text | |
| PersistByteString ByteString | |
| PersistInt64 Int64 | |
| PersistDouble Double | |
| PersistRational Rational | |
| PersistBool Bool | |
| PersistDay Day | |
| PersistTimeOfDay TimeOfDay | |
| PersistUTCTime UTCTime | |
| PersistNull | |
| PersistList [PersistValue] | |
| PersistMap [(Text, PersistValue)] | |
| PersistObjectId ByteString | Intended especially for MongoDB backend |
| PersistDbSpecific ByteString | Using data Geo = Geo ByteString
instance PersistField Geo where
toPersistValue (Geo t) = PersistDbSpecific t
fromPersistValue (PersistDbSpecific t) = Right $ Geo $ Data.ByteString.concat ["'", t, "'"]
fromPersistValue _ = Left "Geo values must be converted from PersistDbSpecific"
instance PersistFieldSql Geo where
sqlType _ = SqlOther "GEOGRAPHY(POINT,4326)"
toPoint :: Double -> Double -> Geo
toPoint lat lon = Geo $ Data.ByteString.concat ["'POINT(", ps $ lon, " ", ps $ lat, ")'"]
where ps = Data.Text.pack . show
If Foo has a geography field, we can then perform insertions like the following: insert $ Foo (toPoint 44 44) |
Instances
A SQL data type. Naming attempts to reflect the underlying Haskell datatypes, eg SqlString instead of SqlVarchar. Different SQL databases may have different translations for these types.
Constructors
| SqlString | |
| SqlInt32 | |
| SqlInt64 | |
| SqlReal | |
| SqlNumeric Word32 Word32 | |
| SqlBool | |
| SqlDay | |
| SqlTime | |
| SqlDayTime | Always uses UTC timezone |
| SqlBlob | |
| SqlOther Text | a backend-specific name |