:wave: , is there any way to merge tables from two...
# exposed
m
đź‘‹ , is there any way to merge tables from two columns to avoid repetitions? ( mixin pattern ) was trying something like this
Copy code
interface DateTableMixin {
    val createdAt: Column<LocalDateTime>
    val updatedAt: Column<LocalDateTime?>

    companion object : Table(), DateTableMixin {
        override val createdAt = datetime("created_at").clientDefault { localDateTimeUTC() }
        override val updatedAt = datetime("updated_at").nullable().clientDefault { localDateTimeUTC() }
    }
}
and later
Copy code
object MyTable
    : Table("my_table"),
    DateTableMixin by DateTableMixin.Companion {
    // created at and updated at available here
}
however the column in the mixin is never registered in the real table so it doesn’t work one option is to override the
getColumns
function but I am pretty sure that will break things down the line
a
you could use normal inheritance, though this of course only works with a single parent class
Copy code
abstract class TableWithTimestamps(tableName: String) : Table(tableName) {
    val createdAt = datetime("created_at").clientDefault { localDateTimeUTC() }
    val updatedAt = datetime("updated_at").nullable().clientDefault { localDateTimeUTC() }
}

object TableA : TableWithTimestamps("table_a") {
    val anotherColumn = int("another_column")
}