Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Since: 1.0.0.0
Synopsis
- data ConstraintDefinition
- uniqueConstraint :: NonEmpty FieldName -> ConstraintDefinition
- foreignKeyConstraint :: TableIdentifier -> NonEmpty ForeignReference -> ConstraintDefinition
- foreignKeyConstraintWithOptions :: TableIdentifier -> NonEmpty ForeignReference -> ForeignKeyOptions -> ConstraintDefinition
- data ForeignReference = ForeignReference {}
- foreignReference :: FieldName -> FieldName -> ForeignReference
- data ConstraintMigrationKey = ConstraintMigrationKey {
- constraintKeyType :: ConstraintKeyType
- constraintKeyColumns :: Maybe [FieldName]
- constraintKeyForeignTable :: Maybe TableIdentifier
- constraintKeyForeignColumns :: Maybe [FieldName]
- constraintKeyForeignKeyOnUpdateAction :: Maybe ForeignKeyAction
- constraintKeyForeignKeyOnDeleteAction :: Maybe ForeignKeyAction
- data ConstraintKeyType
- constraintMigrationKey :: ConstraintDefinition -> ConstraintMigrationKey
- constraintSqlExpr :: ConstraintDefinition -> TableConstraint
- data ForeignKeyAction
- = NoAction
- | Restrict
- | Cascade
- | SetNull
- | SetDefault
- data ForeignKeyOptions
- defaultForeignKeyOptions :: ForeignKeyOptions
- data TableConstraints
- emptyTableConstraints :: TableConstraints
- addConstraint :: ConstraintDefinition -> TableConstraints -> TableConstraints
- tableConstraintDefinitions :: TableConstraints -> [ConstraintDefinition]
- tableConstraintKeys :: TableConstraints -> Set ConstraintMigrationKey
Documentation
data ConstraintDefinition Source #
Defines a constraint that can be added to a
TableDefinition
. Use one of the constructor functions
below (such as uniqueConstraint
) to construct the constraint definition you
wish to have and then use addTableConstraints
to add
them to your table definition. Orville will then add the constraint next time
you run auto-migrations.
Since: 1.0.0.0
uniqueConstraint :: NonEmpty FieldName -> ConstraintDefinition Source #
Constructs a ConstraintDefinition
for a UNIQUE
constraint on the given
columns.
Since: 1.0.0.0
:: TableIdentifier | Identifier of the table referenced by the foreign key. |
-> NonEmpty ForeignReference | The columns constrained by the foreign key and those that they reference in the foreign table. |
-> ConstraintDefinition |
Builds a ConstraintDefinition
for a FOREIGN KEY
constraint.
Since: 1.0.0.0
foreignKeyConstraintWithOptions Source #
:: TableIdentifier | Identifier of the table referenced by the foreign key. |
-> NonEmpty ForeignReference | The columns constrained by the foreign key and those that they reference in the foreign table. |
-> ForeignKeyOptions | |
-> ConstraintDefinition |
Builds a ConstraintDefinition
for a FOREIGN KEY
constraint, with
ON UPDATE and ON DELETE actions.
Since: 1.0.0.0
data ForeignReference Source #
A ForeignReference
represents one part of a foreign key. The entire foreign
key may comprise multiple columns. The ForeignReference
defines a single
column in the key and which column it references in the foreign table.
Since: 1.0.0.0
:: FieldName | The name of the field in the table with the constraint. |
-> FieldName | The name of the field in the foreign table that the local field references. |
-> ForeignReference |
Constructs a ForeignReference
.
Since: 1.0.0.0
data ConstraintMigrationKey Source #
The key used by Orville to determine whether a constraint should be added to
a table when performing auto-migrations. For most use cases, the constructor
functions that build a ConstraintDefinition
will create this automatically
for you.
Since: 1.0.0.0
Instances
data ConstraintKeyType Source #
The kind of constraint that is described by a ConstraintMigrationKey
(e.g.
unique, foreign key).
Since: 1.0.0.0
Instances
Show ConstraintKeyType Source # | |
Defined in Orville.PostgreSQL.Schema.ConstraintDefinition showsPrec :: Int -> ConstraintKeyType -> ShowS # show :: ConstraintKeyType -> String # showList :: [ConstraintKeyType] -> ShowS # | |
Eq ConstraintKeyType Source # | |
Defined in Orville.PostgreSQL.Schema.ConstraintDefinition (==) :: ConstraintKeyType -> ConstraintKeyType -> Bool # (/=) :: ConstraintKeyType -> ConstraintKeyType -> Bool # | |
Ord ConstraintKeyType Source # | |
Defined in Orville.PostgreSQL.Schema.ConstraintDefinition compare :: ConstraintKeyType -> ConstraintKeyType -> Ordering # (<) :: ConstraintKeyType -> ConstraintKeyType -> Bool # (<=) :: ConstraintKeyType -> ConstraintKeyType -> Bool # (>) :: ConstraintKeyType -> ConstraintKeyType -> Bool # (>=) :: ConstraintKeyType -> ConstraintKeyType -> Bool # max :: ConstraintKeyType -> ConstraintKeyType -> ConstraintKeyType # min :: ConstraintKeyType -> ConstraintKeyType -> ConstraintKeyType # |
constraintMigrationKey :: ConstraintDefinition -> ConstraintMigrationKey Source #
Gets the ConstraintMigrationKey
for the ConstraintDefinition
.
Since: 1.0.0.0
constraintSqlExpr :: ConstraintDefinition -> TableConstraint Source #
Gets the SQL expression that will be used to add the constraint to the table.
Since: 1.0.0.0
data ForeignKeyAction Source #
The actions that can be set on ForeignKeyOptions
.
Since: 1.0.0.0
Instances
Show ForeignKeyAction Source # | |
Defined in Orville.PostgreSQL.Schema.ConstraintDefinition showsPrec :: Int -> ForeignKeyAction -> ShowS # show :: ForeignKeyAction -> String # showList :: [ForeignKeyAction] -> ShowS # | |
Eq ForeignKeyAction Source # | |
Defined in Orville.PostgreSQL.Schema.ConstraintDefinition (==) :: ForeignKeyAction -> ForeignKeyAction -> Bool # (/=) :: ForeignKeyAction -> ForeignKeyAction -> Bool # | |
Ord ForeignKeyAction Source # | |
Defined in Orville.PostgreSQL.Schema.ConstraintDefinition compare :: ForeignKeyAction -> ForeignKeyAction -> Ordering # (<) :: ForeignKeyAction -> ForeignKeyAction -> Bool # (<=) :: ForeignKeyAction -> ForeignKeyAction -> Bool # (>) :: ForeignKeyAction -> ForeignKeyAction -> Bool # (>=) :: ForeignKeyAction -> ForeignKeyAction -> Bool # max :: ForeignKeyAction -> ForeignKeyAction -> ForeignKeyAction # min :: ForeignKeyAction -> ForeignKeyAction -> ForeignKeyAction # |
data ForeignKeyOptions Source #
Defines the options for a foreign key constraint. To construct
ForeignKeyOptions
, perform a record update on defaultForeignKeyOptions
.
Since: 1.0.0.0
defaultForeignKeyOptions :: ForeignKeyOptions Source #
The default ForeignKeyOptions
, containing NoAction
for both
foreignKeyOptionsOnUpdate
and foreignKeyOptionsOnDelete
.
Since: 1.0.0.0
data TableConstraints Source #
A collection of constraints to be added to a table. This collection is
indexed by ConstraintMigrationKey
. If multiple constraints with the same
ConstraintMigrationKey
are added, the most recently-added one will be kept
and the previous one dropped.
Since: 1.0.0.0
Instances
emptyTableConstraints :: TableConstraints Source #
Constructs an empty TableConstraints
.
Since: 1.0.0.0
addConstraint :: ConstraintDefinition -> TableConstraints -> TableConstraints Source #
Adds a ConstraintDefinition
to an existing TableConstraints
. If a
constraint already exists with the same ConstraintMigrationKey
, it is
replaced with the new constraint.
Since: 1.0.0.0
tableConstraintDefinitions :: TableConstraints -> [ConstraintDefinition] Source #
Gets the list of ConstraintDefinition
s that have been added to the
TableConstraints
.
Since: 1.0.0.0
tableConstraintKeys :: TableConstraints -> Set ConstraintMigrationKey Source #
Gets the list of ConstraintDefinition
s that have been added to the
TableConstraints
.
Since: 1.0.0.0