Just wanted to follow up on the integration testing with the database. Have you made any progress on that front?
IMHO, it would be ideal to have a workflow where we can spin up a new database for each test, rather than per test suite. This approach allows for better isolation and ensures that tests are not dependent on each other.
Additionally, I’ve found that writing SQL directly and generating corresponding models using the SQL code makes it easier to create and maintain the database structures. Apart from that, tools like flyway can be helpful for version controlling the database and managing relations. I highly recommend considering the use of a database migration tool to ensure proper version control.
Furthermore, I personally prefer writing SQL or SQL-like queries (such as JOOQ for Java) rather than relying on highly abstracted ORMs. While ORMs can sometimes increase productivity, they may not always be the most efficient solution when it comes to performance. Writing SQL queries gives us more control and allows us to optimize them for better execution.
Let me know if you have any thoughts or questions regarding these suggestions.
The major difference in the suggestion that @jaye has made here is the fact that we don’t really need an ORM but only a simple library that can write native-like SQL queries programatically with typescript. Then we can rely on hand written raw SQL for data definition. A quick google search led me to find this library called Knex.js that perfectly fits the description. That being said I’m not completely against the idea of employing an ORM so there’s very little to take care of in the database level. But that luxury does come with a cost. Personally I’d to prefer the path of not using the ORM but that’s a subjective opinion. See what fits the best for the project and make the best decision.
As I understood, Flyway is used for version-controlling the databases. If we use a database schema file or ORM for generating the database tables, why do we need a tool like Flyway when we can simply use Git? Wouldn’t that make things more complex?