postgresql-orm-0.5.0: An ORM (Object Relational Mapping) and migrations DSL for PostgreSQL.

Safe HaskellNone
LanguageHaskell2010

Database.PostgreSQL.ORM.CreateTable

Description

Functions for creating a table from a model. These are mostly useful in development, for very rigid applications, or to compare what would be created against what is actually in the database. In practice, production settings should create and update tables using migrations.

Note that often it is more interesting to see what would be created than to create an actual table. For that reason, functions creating the statements are exposed.

Synopsis

Documentation

modelCreateStatement :: forall a. (Model a, Generic a, GDefTypes (Rep a)) => a -> Query Source #

Statement for creating the table corresponding to a model. Not strict in its argument.

modelCreate :: (Model a, Generic a, GDefTypes (Rep a)) => Connection -> a -> IO Int64 Source #

Create a the database table for a model.

class GDefTypes f where Source #

This is a helper class used to extract the row types. You don't need to use this class. If you are creating custom types, just declare an instance of SqlType.

Minimal complete definition

gDefTypes

Methods

gDefTypes :: f p -> [ByteString] Source #

Instances

SqlType c => GDefTypes (K1 * i c) Source # 

Methods

gDefTypes :: K1 * i c p -> [ByteString] Source #

(GDefTypes a, GDefTypes b) => GDefTypes ((:*:) * a b) Source # 

Methods

gDefTypes :: (* :*: a) b p -> [ByteString] Source #

GDefTypes f => GDefTypes (M1 * i c f) Source # 

Methods

gDefTypes :: M1 * i c f p -> [ByteString] Source #

jtCreateStatement :: (Model a, Model b) => JoinTable a b -> Query Source #

Create the database table corresponding to a JoinTable.

jtCreate :: (Model a, Model b) => Connection -> JoinTable a b -> IO Int64 Source #

Create a join table in the database.