persistent-postgresql-2.13.7.0: Backend for the persistent library using postgresql.

Safe Haskell | None
Language | Haskell2010

Database.Persist.Postgresql.Internal

Synopsis

- newtype P = P {
  - unP :: PersistValue
  }
- newtype PgInterval = PgInterval {
  - getPgInterval :: NominalDiffTime
  }
- getGetter :: Oid -> Getter PersistValue
- data AlterDB
  - = AddTable EntityNameDB EntityIdDef [Column]
  - | AlterColumn EntityNameDB AlterColumn
  - | AlterTable EntityNameDB AlterTable
- data AlterTable
  - = AddUniqueConstraint ConstraintNameDB [FieldNameDB]
  - | DropConstraint ConstraintNameDB
- data AlterColumn
  - = ChangeType Column SqlType Text
  - | IsNull Column
  - | NotNull Column
  - | AddColumn Column
  - | Drop Column SafeToRemove
  - | Default Column Text
  - | NoDefault Column
  - | UpdateNullToValue Column Text
  - | AddReference EntityNameDB ConstraintNameDB (NonEmpty FieldNameDB) [Text] FieldCascade
  - | DropReference ConstraintNameDB
- data SafeToRemove
- migrateStructured :: [EntityDef] -> (Text -> IO Statement) -> EntityDef -> IO (Either [Text] [AlterDB])
- mockMigrateStructured :: [EntityDef] -> EntityDef -> [AlterDB]
- addTable :: [Column] -> EntityDef -> AlterDB
- findAlters :: [EntityDef] -> EntityDef -> Column -> [Column] -> ([AlterColumn], [Column])
- maySerial :: SqlType -> Maybe Text -> Text
- mayDefault :: Maybe Text -> Text
- showSqlType :: SqlType -> Text
- showColumn :: Column -> Text
- showAlter :: EntityNameDB -> AlterColumn -> Text
- showAlterDb :: AlterDB -> (Bool, Text)
- showAlterTable :: EntityNameDB -> AlterTable -> Text
- getAddReference :: [EntityDef] -> EntityDef -> FieldNameDB -> ColumnReference -> Maybe AlterDB
- udToPair :: UniqueDef -> (ConstraintNameDB, [FieldNameDB])
- safeToRemove :: EntityDef -> FieldNameDB -> Bool
- postgresMkColumns :: [EntityDef] -> EntityDef -> ([Column], [UniqueDef], [ForeignDef])
- getAlters :: [EntityDef] -> EntityDef -> ([Column], [(ConstraintNameDB, [FieldNameDB])]) -> ([Column], [(ConstraintNameDB, [FieldNameDB])]) -> ([AlterColumn], [AlterTable])
- escapeE :: EntityNameDB -> Text
- escapeF :: FieldNameDB -> Text
- escape :: Text -> Text

# Documentation

newtype P Source #

Newtype used to avoid orphan instances for `postgresql-simple` classes.

Since: 2.13.2.0

Constructors

P |

Fields

- unP :: PersistValue

#### Instances

Instances details

FromField P Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods fromField :: FieldParser P Source #
ToField P Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods toField :: P -> Action Source #

newtype PgInterval Source #

Represent Postgres interval using NominalDiffTime

Since: 2.11.0.0

Constructors

PgInterval |

Fields

- getPgInterval :: NominalDiffTime

#### Instances

Instances details

Show PgInterval Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods showsPrec :: Int -> PgInterval -> ShowS Source # show :: PgInterval -> String Source # showList :: [PgInterval] -> ShowS Source #
Eq PgInterval Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods (==) :: PgInterval -> PgInterval -> Bool Source # (/=) :: PgInterval -> PgInterval -> Bool Source #
PersistField PgInterval Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods toPersistValue :: PgInterval -> PersistValue Source # fromPersistValue :: PersistValue -> Either Text PgInterval Source #
PersistFieldSql PgInterval Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods sqlType :: Proxy PgInterval -> SqlType Source #
FromField PgInterval Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods fromField :: FieldParser PgInterval Source #
ToField PgInterval Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods toField :: PgInterval -> Action Source #

getGetter :: Oid -> Getter PersistValue Source #

Get the field parser corresponding to the given `Oid`.

For example, pass in the `Oid` of `bool`, and you will get back a field parser which parses boolean values in the table into `PersistBool`s.

Since: 2.13.2.0

data AlterDB Source #

Represents a change to a Postgres DB in a statement.

Since: 2.17.1.0

Constructors

AddTable EntityNameDB EntityIdDef [Column] |
AlterColumn EntityNameDB AlterColumn |
AlterTable EntityNameDB AlterTable |

#### Instances

Instances details

Show AlterDB Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods showsPrec :: Int -> AlterDB -> ShowS Source # show :: AlterDB -> String Source # showList :: [AlterDB] -> ShowS Source #
Eq AlterDB Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods (==) :: AlterDB -> AlterDB -> Bool Source # (/=) :: AlterDB -> AlterDB -> Bool Source #

data AlterTable Source #

Represents a change to a Postgres table in a DB statement.

Since: 2.17.1.0

Constructors

AddUniqueConstraint ConstraintNameDB [FieldNameDB] |
DropConstraint ConstraintNameDB |

#### Instances

Instances details

Show AlterTable Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods showsPrec :: Int -> AlterTable -> ShowS Source # show :: AlterTable -> String Source # showList :: [AlterTable] -> ShowS Source #
Eq AlterTable Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods (==) :: AlterTable -> AlterTable -> Bool Source # (/=) :: AlterTable -> AlterTable -> Bool Source #

data AlterColumn Source #

Represents a change to a Postgres column in a DB statement.

Since: 2.17.1.0

Constructors

ChangeType Column SqlType Text |
IsNull Column |
NotNull Column |
AddColumn Column |
Drop Column SafeToRemove |
Default Column Text |
NoDefault Column |
UpdateNullToValue Column Text |
AddReference EntityNameDB ConstraintNameDB (NonEmpty FieldNameDB) [Text] FieldCascade |
DropReference ConstraintNameDB |

#### Instances

Instances details

Show AlterColumn Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods showsPrec :: Int -> AlterColumn -> ShowS Source # show :: AlterColumn -> String Source # showList :: [AlterColumn] -> ShowS Source #
Eq AlterColumn Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods (==) :: AlterColumn -> AlterColumn -> Bool Source # (/=) :: AlterColumn -> AlterColumn -> Bool Source #

data SafeToRemove Source #

Indicates whether a Postgres Column is safe to drop.

Since: 2.17.1.0

#### Instances

Instances details

Show SafeToRemove Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods showsPrec :: Int -> SafeToRemove -> ShowS Source # show :: SafeToRemove -> String Source # showList :: [SafeToRemove] -> ShowS Source #
Eq SafeToRemove Source # |
Instance details Defined in Database.Persist.Postgresql.Internal Methods (==) :: SafeToRemove -> SafeToRemove -> Bool Source # (/=) :: SafeToRemove -> SafeToRemove -> Bool Source #

migrateStructured :: [EntityDef] -> (Text -> IO Statement) -> EntityDef -> IO (Either [Text] [AlterDB]) Source #

Returns a structured representation of all of the DB changes required to migrate the Entity from its current state in the database to the state described in Haskell.

Since: 2.17.1.0

mockMigrateStructured :: [EntityDef] -> EntityDef -> [AlterDB] Source #

Returns a structured representation of all of the DB changes required to migrate the Entity to the state described in Haskell, assuming it currently does not exist in the database.

Since: 2.17.1.0

addTable :: [Column] -> EntityDef -> AlterDB Source #

Returns a structured representation of all of the DB changes required to migrate the Entity from its current state in the database to the state described in Haskell.

Since: 2.17.1.0

findAlters Source #

Arguments

:: [EntityDef] | The list of all entity definitions that persistent is aware of.
-> EntityDef | The entity definition for the entity that we're working on.
-> Column | The column that we're searching for potential alterations for.
-> [Column] |
-> ([AlterColumn], [Column]) |

maySerial :: SqlType -> Maybe Text -> Text Source #

mayDefault :: Maybe Text -> Text Source #

showSqlType :: SqlType -> Text Source #

showColumn :: Column -> Text Source #

showAlter :: EntityNameDB -> AlterColumn -> Text Source #

showAlterDb :: AlterDB -> (Bool, Text) Source #

showAlterTable :: EntityNameDB -> AlterTable -> Text Source #

getAddReference :: [EntityDef] -> EntityDef -> FieldNameDB -> ColumnReference -> Maybe AlterDB Source #

Get the references to be added to a table for the given column.

udToPair :: UniqueDef -> (ConstraintNameDB, [FieldNameDB]) Source #

safeToRemove :: EntityDef -> FieldNameDB -> Bool Source #

Check if a column name is listed as the "safe to remove" in the entity list.

postgresMkColumns :: [EntityDef] -> EntityDef -> ([Column], [UniqueDef], [ForeignDef]) Source #

getAlters :: [EntityDef] -> EntityDef -> ([Column], [(ConstraintNameDB, [FieldNameDB])]) -> ([Column], [(ConstraintNameDB, [FieldNameDB])]) -> ([AlterColumn], [AlterTable]) Source #

escapeE :: EntityNameDB -> Text Source #

escapeF :: FieldNameDB -> Text Source #

escape :: Text -> Text Source #