My application backend consists of a bunch of standalone tasks linked together by messaging queues. They all need to access the same SQL database in order to run and store their results. Right now, all the tasks are accessing the SQL database directly, but by not having a centralized entity to manage access to that database, I am not sure how to maintain the database (apply migrations, ...).
One solution would be to access the database through an API, which would be in charge of maintaining the database. This approach also has the advantage of decoupling the datastore implementation from the application code. On the other hand, the application has to do very expensive queries (insert a 500MB CSV in a table for example), and I'm not sure how performance could be impacted for such a use case.
What's the "recommended" way of architecting such a system?