by _Codemonkeyism · 8y ago · 0 comments
We now migrate to PG using 'core' attributes in tables and 'flexible' attributes in JSONB to get the best of two worlds.
I agree to the API problem, JDBC and PG/SQL is not as nice as a interace compared to Mongo libs.
Adding and removing happens on the application layer with using Option[_] monads in the data model. Add a field means add Option[_], removing a field means making e.g. String an Option[String] - or fill with default values on read. If we drop a field over time we ignore it during writes.
case class Person(name:String)
adding a job field after some time becomes case class Person(name:String, job:Option[String])
and application code needs to deal with it.Works for us, compared to my previous jobs where we used SQL and migrations.