| Copyright | Flipstone Technology Partners 2023 |
|---|---|
| License | MIT |
| Stability | Stable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Orville.PostgreSQL.Expr.TableDefinition
Description
Since: 1.0.0.0
Synopsis
- data CreateTableExpr
- createTableExpr :: Qualified TableName -> [ColumnDefinition] -> Maybe PrimaryKeyExpr -> [TableConstraint] -> CreateTableExpr
- data PrimaryKeyExpr
- primaryKeyExpr :: NonEmpty ColumnName -> PrimaryKeyExpr
- data AlterTableExpr
- alterTableExpr :: Qualified TableName -> NonEmpty AlterTableAction -> AlterTableExpr
- data AlterTableAction
- addColumn :: ColumnDefinition -> AlterTableAction
- dropColumn :: ColumnName -> AlterTableAction
- addConstraint :: TableConstraint -> AlterTableAction
- dropConstraint :: ConstraintName -> AlterTableAction
- alterColumnType :: ColumnName -> DataType -> Maybe UsingClause -> AlterTableAction
- alterColumnSetDefault :: SqlExpression valueExpression => ColumnName -> valueExpression -> AlterTableAction
- alterColumnDropDefault :: ColumnName -> AlterTableAction
- data UsingClause
- usingCast :: ColumnName -> DataType -> UsingClause
- alterColumnNullability :: ColumnName -> AlterNotNull -> AlterTableAction
- data AlterNotNull
- setNotNull :: AlterNotNull
- dropNotNull :: AlterNotNull
- data DropTableExpr
- dropTableExpr :: Maybe IfExists -> Qualified TableName -> DropTableExpr
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
Instances
| SqlExpression CreateTableExpr Source # | |
Defined in Orville.PostgreSQL.Expr.TableDefinition Methods toRawSql :: CreateTableExpr -> RawSql 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
Instances
| SqlExpression PrimaryKeyExpr Source # | |
Defined in Orville.PostgreSQL.Expr.TableDefinition Methods toRawSql :: PrimaryKeyExpr -> RawSql Source # | |
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
Instances
| SqlExpression AlterTableExpr Source # | |
Defined in Orville.PostgreSQL.Expr.TableDefinition Methods toRawSql :: AlterTableExpr -> RawSql Source # | |
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
Instances
| SqlExpression AlterTableAction Source # | |
Defined in Orville.PostgreSQL.Expr.TableDefinition Methods toRawSql :: AlterTableAction -> RawSql Source # | |
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
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 |
| -> 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
Instances
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
Instances
| SqlExpression AlterNotNull Source # | |
Defined in Orville.PostgreSQL.Expr.TableDefinition Methods toRawSql :: AlterNotNull -> RawSql Source # | |
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
Instances
| SqlExpression DropTableExpr Source # | |
Defined in Orville.PostgreSQL.Expr.TableDefinition Methods toRawSql :: DropTableExpr -> RawSql Source # | |
dropTableExpr :: Maybe IfExists -> Qualified TableName -> DropTableExpr Source #
Constructs a DropTableExpr that will drop the specified table.
Since: 1.0.0.0