autoIncrement

Marks this INTEGER PRIMARY KEY column of type Long to AUTOINCREMENT.

This function is applicable only to columns of type Long that are also defined as a PRIMARY KEY. It enables SQLite's AUTOINCREMENT behavior, which ensures that newly generated row IDs are always monotonically increasing and are never reused, even after previous rows have been deleted.

This constraint is typically used for creating unique, surrogate keys. An AUTOINCREMENT column must also be a PRIMARY KEY.

Example:

object Users : KQLiteTable("users") {
// 'id' will be a primary key that automatically increments.
val id = longColumn("id").primaryKey().autoIncrement()
val name = stringColumn("name").notNull()
}

Return

The same KQLiteColumn instance, now marked as auto-incrementing, to allow for further chaining.

Author

MOHAMMAD AZIM ANSARI

See also

Throws

if applied to a column that is not a PRIMARY KEY. (Note: This is a design consideration; current implementation may not enforce it at compile time).