zekroTJA / shinpuru

シンプル - Discord Bot with role selection, moderation, karma ranking, a starboard, code execution, raid alerting, backups, a web interface, twitch notifications and more!
https://shnp.de
MIT License
187 stars 37 forks source link

Postgres support #446

Open JJGadgets opened 7 months ago

JJGadgets commented 7 months ago

Type

Enhancement of an existing feature

Description

It would be nice to have Postgres support for Shinpuru, as I planned to selfhost this on my home Kubernetes cluster which has a Postgres Kubernetes operator installed and running to automate and manage replication, backups/restores (including streaming WALs, I can delete the Postgres cluster and reapply the cluster YAML and it'll restore and reconfigure everything automatically), credentials and other aspects of Postgres clusters.

MySQL/MariaDB Kubernetes operators are IMO less battle tested and stable than Postgres operators, and it seems like Shinpuru has been setup in a way that allows supporting other databases more readily (feel free to correct me if I'm wrong).

Attachments

No response

zekroTJA commented 7 months ago

Hey! First of all, thank you for your suggestion!

Generally, the general implementation and configuration of the database would support different other database implementations next to MySQL/MariaDB.

I am actually planning a re-write of the whole database structure, which is still around and almost untouched since the creation of the bot, where I was still pretty novice to database concepts and thus, the implementation is pretty poor. But because there are so much dependencies on the database and because the current system kind of works, I did not prioritize to redo the whole thing yet.

Currently, I do some refactoring to re-work the whole dependency coupling between the different modules of shinpuru. When I am done with that, I would take a try on re-implementing the database in a more efficient way, where I would also support multiple other database types, but this might take a long time until it is ready to use.

Currently, the easiest and fastest way to support postgres would be to somewhat copy the current MySQL implementation but with postgres queries. But I would prefer to focus on the method path before because it is more future proof.

But if you really need the postgres implementation, I am also very open for a PR, if you have the time and interest. If you want to do so, feel free to contact me if you need help. :)