ForeignKeyConstraint

Represents a FOREIGN KEY in a KQLiteTable.

This interface provides a fluent API to build a complete foreign key definition, including specifying the referenced parent table columns and defining actions for ForeignKeyConstraint.onDelete and ForeignKeyConstraint.onUpdate.

Example

// Inside KQLiteTable
override val constraints: (ConstraintBuilder.() -> Unit)? = {
foreignKey(columnA, columnB)
.references(ParentTable.columnX, ParentTable.columnY)
.onDelete(ForeignKeyAction.CASCADE)
.onUpdate(ForeignKeyAction.NO_ACTION)
.deferrable(true)
.initially(Initially.DEFERRED)
}

Author

MOHAMMAD AZIM ANSARI

See also

Functions

Link copied to clipboard

Same as calling deferrable(allow = true)

This corresponds to the DEFERRABLE clause in a FOREIGN KEY definition.

Link copied to clipboard
abstract fun initially(initially: Initially): Constraint

This corresponds to the INITIALLY clause in a FOREIGN KEY definition.

Link copied to clipboard

This corresponds to the ON DELETE clause in a FOREIGN KEY definition.

Link copied to clipboard

This corresponds to the ON UPDATE clause in a FOREIGN KEY definition.

Link copied to clipboard
abstract fun references(vararg column: KQLiteColumn<*>): ForeignKeyConstraint

This corresponds to the REFERENCES clause in a FOREIGN KEY definition.