Hey guys, am having a small problem in declaring a...
# exposed
d
Hey guys, am having a small problem in declaring a primary key in table. Am using Exposed framework and my base table is Table("users"). unfortunately, am unable to declare my user_id as a primary key. I get this error Unresolved reference: primaryKey here is my table implementation object Users : Table("users"){ val userId: Column<Int> = integer("user_id").autoIncrement("user_id_seq").primaryKey() val createdAt = datetime("created_at").defaultExpression(CurrentDateTime) val updatedAt = datetime("updated_at").defaultExpression(CurrentDateTime) val accountId = integer("account_id") val msisdn = varchar("msisdn", length = 100).nullable() val firstName = varchar("first_name", length = 100).nullable() val middleName = varchar("middle_name", length = 100).nullable() val lastName = varchar("last_name", length = 100).nullable() val emailAddress = varchar("email_address", length = 100).nullable() val username = varchar("username", length = 100).nullable() val password = varchar("password", length = 100).nullable() val userStatus = char("user_status", length = 8) }
c
Version 0.36.1 moved away from
Column.primaryKey()
. A primary key can now be declared like this:
Copy code
object Users : Table("users") {
    val userId: Column<Int> = integer("user_id").autoIncrement("user_id_seq")
    // other columns

    override val primaryKey = PrimaryKey(userId)
}
d
Thank you ! @Chantal Loncle
👍 1