Manasseh
07/30/2023, 12:13 AMAndromadus Naruto
07/30/2023, 7:55 AM// Users
// Users
object UserTable : IntIdTable("users") {
val uid = varchar("uid", 50).uniqueIndex()
val email = varchar("email", 180).uniqueIndex()
val password = varchar("password", 4096)
}
// Profile
object UserProfileTable : IntIdTable("user_profiles") {
val full_name = varchar("full_name", 100)
// relations
val user_id = references("user_id", UserTable) // uses the ID field of UserTable as foreign key reference
// val user_uid = references("user_uid", UserTable.uid) // if you want to use another field other than ID field as a foreign key reference
}
// Order
object OrderTable : IntIdTable("orders") {
val order_no = varchar("order_no").uniqueIndex()
val date_ordered = datetime("date_ordered")
val status = varchar("status", 50)
// relations
val user_id = references("user_id", UserTable)
}
Manasseh
07/30/2023, 7:57 AMManasseh
07/30/2023, 7:58 AMobject Profiles : IntIdTable() {
val name: Column<String?> = varchar("name", 50).nullable()
val bio: Column<String?> = varchar("bio", 50).nullable()
val location: Column<String?> = varchar("location", 50).nullable()
val website: Column<String?> = varchar("website", 100).nullable()
val displayPicture: Column<ExposedBlob?> = blob("display_picture").nullable()
val bannerPicture: Column<ExposedBlob?> = blob("banner_picture").nullable()
val dateOfBirth: Column<LocalDate> = date("date_of_birth")
val userId = reference("user_id", Users).uniqueIndex() // relation
}
Andromadus Naruto
07/30/2023, 7:59 AMAndromadus Naruto
07/30/2023, 8:00 AMManasseh
07/30/2023, 8:01 AMval user_id = references("user_id", UserTable)
Andromadus Naruto
07/30/2023, 8:04 AMval userId = reference("user_id", Users).uniqueIndex() // relation
Manasseh
07/30/2023, 8:05 AMManasseh
07/30/2023, 8:05 AMManasseh
07/30/2023, 8:05 AMAndromadus Naruto
07/30/2023, 8:07 AMManasseh
07/30/2023, 8:08 AM