beam-migrate-0.2.0.0: SQL DDL support and migrations support library for Beam

Safe HaskellNone
LanguageHaskell2010

Database.Beam.Migrate.Generics

Contents

Description

Support for creating checked databases from Haskell ADTs, using Generics.

For more information, see the manual

Synopsis

Default checked database settings

defaultMigratableDbSettings :: forall syntax be db. (Generic (CheckedDatabaseSettings be db), GAutoMigratableDb syntax (Rep (CheckedDatabaseSettings be db))) => CheckedDatabaseSettings be db Source #

Produce a checked database for the given Haskell database type

See the manual for more information on the defaults.

Extending the defaulting sytem

class IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax ty where Source #

Used to define a default SQL data type for a haskell type in a particular data type syntax.

Beam defines instances for several standard SQL types, which are polymorphic over any standard data type syntax. Backends or extensions which provide custom types should instantiate instances of this class and HasDefaultSqlDataTypeConstraints for any types they provide for which they would like checked schema migrations

Minimal complete definition

defaultSqlDataType

Methods

defaultSqlDataType Source #

Arguments

:: Proxy ty

Concrete representation of the type

-> Bool

True if this field is in an embedded key or table, False otherwise

-> dataTypeSyntax 

Provide a data type for the given type

Instances

IsSql99DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Bool Source # 

Methods

defaultSqlDataType :: Proxy * Bool -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Day Source # 

Methods

defaultSqlDataType :: Proxy * Day -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Scientific Source # 

Methods

defaultSqlDataType :: Proxy * Scientific -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Double Source # 

Methods

defaultSqlDataType :: Proxy * Double -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax SqlBitString Source # 

Methods

defaultSqlDataType :: Proxy * SqlBitString -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Text Source # 

Methods

defaultSqlDataType :: Proxy * Text -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Word64 Source # 

Methods

defaultSqlDataType :: Proxy * Word64 -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Word32 Source # 

Methods

defaultSqlDataType :: Proxy * Word32 -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Word16 Source # 

Methods

defaultSqlDataType :: Proxy * Word16 -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Word Source # 

Methods

defaultSqlDataType :: Proxy * Word -> Bool -> dataTypeSyntax Source #

IsSql2008BigIntDataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Int64 Source # 

Methods

defaultSqlDataType :: Proxy * Int64 -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Int16 Source # 

Methods

defaultSqlDataType :: Proxy * Int16 -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Int32 Source # 

Methods

defaultSqlDataType :: Proxy * Int32 -> Bool -> dataTypeSyntax Source #

IsSql92DataTypeSyntax dataTypeSyntax => HasDefaultSqlDataType dataTypeSyntax Int Source # 

Methods

defaultSqlDataType :: Proxy * Int -> Bool -> dataTypeSyntax Source #

(IsSql92DataTypeSyntax dataTypeSyntax, HasDefaultSqlDataType dataTypeSyntax ty) => HasDefaultSqlDataType dataTypeSyntax (Maybe ty) Source # 

Methods

defaultSqlDataType :: Proxy * (Maybe ty) -> Bool -> dataTypeSyntax Source #

(IsSql92DataTypeSyntax dataTypeSyntax, HasDefaultSqlDataType dataTypeSyntax ty) => HasDefaultSqlDataType dataTypeSyntax (Auto ty) Source # 

Methods

defaultSqlDataType :: Proxy * (Auto ty) -> Bool -> dataTypeSyntax Source #

class IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax ty where Source #

Certain data types also come along with constraints. For example, SERIAL types in Postgres generate an automatic DEFAULT constraint.

You need an instance of this class for any type for which you want beam to be able to infer the SQL data type. If your data type does not have any constraint requirements, you can just declare an empty instance

Methods

defaultSqlDataTypeConstraints Source #

Arguments

:: Proxy ty

Concrete representation of the type

-> Proxy columnSchemaSyntax

Concrete representation of the syntax

-> Bool

True if this field is embedded in a foreign key, False otherwise. For example, SERIAL types in postgres get a DEFAULT constraint, but SERIAL types in a foreign key do not.

-> [FieldCheck] 

Provide arbitrary constraints on a field of the requested type. See FieldCheck for more information on the formatting of constraints.

Instances

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Bool Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Bool -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Day Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Day -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Scientific Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Scientific -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Double Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Double -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax SqlBitString Source # 
IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Text Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Text -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Word64 Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Word64 -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Word32 Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Word32 -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Word16 Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Word16 -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Word Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Word -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Int64 Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Int64 -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Int16 Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Int16 -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Int32 Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Int32 -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

IsSql92ColumnSchemaSyntax columnSchemaSyntax => HasDefaultSqlDataTypeConstraints columnSchemaSyntax Int Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * Int -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

(IsSql92ColumnSchemaSyntax columnSchemaSyntax, HasDefaultSqlDataTypeConstraints columnSchemaSyntax ty) => HasDefaultSqlDataTypeConstraints columnSchemaSyntax (Maybe ty) Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * (Maybe ty) -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

(IsSql92ColumnSchemaSyntax columnSchemaSyntax, HasDefaultSqlDataTypeConstraints columnSchemaSyntax ty) => HasDefaultSqlDataTypeConstraints columnSchemaSyntax (Auto ty) Source # 

Methods

defaultSqlDataTypeConstraints :: Proxy * (Auto ty) -> Proxy * columnSchemaSyntax -> Bool -> [FieldCheck] Source #

type Sql92HasDefaultDataType syntax ty = (HasDefaultSqlDataType (Sql92DdlCommandDataTypeSyntax syntax) ty, HasDefaultSqlDataTypeConstraints (Sql92DdlCommandColumnSchemaSyntax syntax) ty) Source #

Constraint synonym to use if you want to assert that a particular IsSql92Syntax syntax supports defaulting for a particular data type