constraint

abstract fun constraint(name: String): ConstraintBuilder

Specifies a name for the Constraint that follows. Represents CONSTRAINT <name>.

This function is used to assign a custom name to a KQLiteTable level constraint. By naming a constraint, it becomes easier to reference or modify it later.

Example

object Tracks : KQLiteTable("tracks") {
val trackId = longColumn("TrackId").notNull()

override val constraints: (ConstraintBuilder.() -> Unit)? = {
constraint("primary_track").primaryKey(trackId)
}
}

Return

A ConstraintBuilder instance that allows chaining to define the actual constraint type (e.g., primaryKey, unique, check, foreignKey).

Parameters

name

The name to assign to the constraint.