orville-postgresql-1.0.0.0: A Haskell library for PostgreSQL
CopyrightFlipstone Technology Partners 2023
LicenseMIT
StabilityStable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Orville.PostgreSQL.Expr.TableDefinition

Description

Since: 1.0.0.0

Synopsis

Documentation

data CreateTableExpr Source #

Type to represent a CREATE TABLE statement. E.G.

CREATE TABLE foo (id integer)

CreateTableExpr provides a SqlExpression instance. See unsafeSqlExpression for how to construct a value with your own custom SQL.

Since: 1.0.0.0

createTableExpr Source #

Arguments

:: Qualified TableName

The name to be used for the table.

-> [ColumnDefinition]

The columns to include in the table.

-> Maybe PrimaryKeyExpr

A primary key expression for the table.

-> [TableConstraint]

Any table constraints to include with the table.

-> CreateTableExpr 

Constructs a CreateTableExpr with the given options.

Since: 1.0.0.0

data PrimaryKeyExpr Source #

Type to represent the primary key of a table. E.G.

PRIMARY KEY (id)

PrimaryKeyExpr provides a SqlExpression instance. See unsafeSqlExpression for how to construct a value with your own custom SQL.

Since: 1.0.0.0

primaryKeyExpr :: NonEmpty ColumnName -> PrimaryKeyExpr Source #

Constructs a PrimaryKeyExpr with the given columns.

Since: 1.0.0.0

data AlterTableExpr Source #

Type to represent an ALTER TABLE statement. E.G.

ALTER TABLE foo ADD COLUMN bar integer

AlterTableExpr provides a SqlExpression instance. See unsafeSqlExpression for how to construct a value with your own custom SQL.

Since: 1.0.0.0

alterTableExpr :: Qualified TableName -> NonEmpty AlterTableAction -> AlterTableExpr Source #

Constructs an AlterTableExpr with the given alter table actions.

Since: 1.0.0.0

data AlterTableAction Source #

Type to represent an action as part of an ALTER TABLE statement. E.G.

ADD COLUMN bar integer

AlterTableAction provides a SqlExpression instance. See unsafeSqlExpression for how to construct a value with your own custom SQL.

Since: 1.0.0.0

addColumn :: ColumnDefinition -> AlterTableAction Source #

Constructs an AlterTableAction that will add the specified column to the table.

Since: 1.0.0.0

dropColumn :: ColumnName -> AlterTableAction Source #

Constructs an AlterTableAction that will drop the specified column from the table.

Since: 1.0.0.0

addConstraint :: TableConstraint -> AlterTableAction Source #

Constructs an AlterTableAction that will add the specified constraint to the table.

Since: 1.0.0.0

dropConstraint :: ConstraintName -> AlterTableAction Source #

Constructs an AlterTableAction that will drop the specified constraint from the table.

Since: 1.0.0.0

alterColumnType Source #

Arguments

:: ColumnName

The name of the column whose type will be altered.

-> DataType

The new type to use for the column.

-> Maybe UsingClause

An optional UsingClause to indicate to the database how data from the old type should be converted to the new type.

-> AlterTableAction 

Constructs an AlterTableAction that will alter the type of the specified column.

Since: 1.0.0.0

alterColumnSetDefault :: SqlExpression valueExpression => ColumnName -> valueExpression -> AlterTableAction Source #

Constructs an AlterTableAction that will use SET DEFAULT to set the default value of the specified column.

Since: 1.0.0.0

alterColumnDropDefault :: ColumnName -> AlterTableAction Source #

Constructs an AlterTableAction that will use DROP DEFAULT to drop the default value of the specified column.

Since: 1.0.0.0

data UsingClause Source #

Type to represent a USING clause as part of an ALTER COLUMN when changing the type of a column. E.G.

USING id :: integer

UsingClause provides a SqlExpression instance. See unsafeSqlExpression for how to construct a value with your own custom SQL.

Since: 1.0.0.0

usingCast :: ColumnName -> DataType -> UsingClause Source #

Constructs a UsingClause that will cast the column to the specified type.

Since: 1.0.0.0

alterColumnNullability :: ColumnName -> AlterNotNull -> AlterTableAction Source #

Constructs an AlterTableAction that will alter the nullability of the column.

Since: 1.0.0.0

data AlterNotNull Source #

Type to represent an action to alter the nullability of a column. E.G.

SET NOT NULL

AlterNotNull provides a SqlExpression instance. See unsafeSqlExpression for how to construct a value with your own custom SQL.

Since: 1.0.0.0

setNotNull :: AlterNotNull Source #

Sets the column to not null via SET NOT NULL.

Since: 1.0.0.0

dropNotNull :: AlterNotNull Source #

Sets the column to allow null via DROP NOT NULL.

Since: 1.0.0.0

data DropTableExpr Source #

Type to represent a DROP TABLE statement. E.G.

DROP TABLE FOO

DropTableExpr provides a SqlExpression instance. See unsafeSqlExpression for how to construct a value with your own custom SQL.

Since: 1.0.0.0

dropTableExpr :: Maybe IfExists -> Qualified TableName -> DropTableExpr Source #

Constructs a DropTableExpr that will drop the specified table.

Since: 1.0.0.0