Constraint

sealed class Constraint(name: String?)

Represents a base class for all SQL table constraints.

This sealed class provides a common structure for defining various types of constraints that can be applied to table columns.

Following constraints inherit from this class:

Example

object Tracks : KQLiteTable("tracks") {
val trackId = longColumn("TrackId").notNull().autoIncrement()
val trackName = stringColumn("Name").notNull()
val length = timeColumn("Length").notNull()
val unitPrice = doubleColumn("UnitPrice").notNull()

override val constraints: (ConstraintBuilder.() -> Unit)? = {
// Constraint without name
primaryKey(trackId)

// Constraint with name
constraint("p_key_track_name").primaryKey(trackName)
}
}

Author

MOHAMMAD AZIM ANSARI

See also

Constructors

Link copied to clipboard
protected constructor(name: String?)