torrust-tracker
torrust-tracker copied to clipboard
Overhaul persistence
We should review the database layer.
Context
- User has a request for new driver implementation: PostgreSQL
- It seems adding Postgres is tricky with the crate we are using: r2d2
- We don't have migrations. We are using sqlx in the Index.
Problem
- I'm not sure if the package we are using is still the best fit for this project.
- I think we should include migrations if we start making schema changes more often, and it seems we will. For example, I'm planning to add more tables to persist metrics. See https://github.com/torrust/torrust-tracker/issues/1437#issuecomment-2887185631
Proposal
In the middle term (before adding more tables), we should:
- Research to confirm if the current crate is the best one. Change it if it's not.
- Add migrations.
- Split the database trait into many different traits per context. Otherwise, it will end up having too many methods.
I think I will implement the metrics persistence with the current drivers because I want to finish the stats overhaul, but we should consider implementing this epic before continuing to add more tables (complexity) to the current persistence layer, especially if we decide to change it.
cc @da2ce7