strinking / futaba

Discord bot for the Programming server
MIT License
28 stars 10 forks source link

Make SQL tables for cogs dynamic #13

Open Ma-wa-re opened 6 years ago

Ma-wa-re commented 6 years ago

Instead of all tables needed for cogs being static and needing added in sql to be made at init time. When a cog is loaded it can request a table to be made for it to make it more dynamic and not require 3rd party devs making cogs to touch the base bot. Doing this will mean tables for cogs that are not being used are created

emmiegit commented 5 years ago

This will also require manually firing off the on_guild_join and on_guild_leave events on cog load/unload if applicable. The difference is done by checking the SQL guilds list with the client's guild list, but the SQL is updated right after the hooks are run. So we'll need to store the diffs in the client somewhere for the entire length of the bot's life.

emmiegit commented 5 years ago

Remember to update CONTRIBUTING.md too

Ma-wa-re commented 4 years ago

Update: As I am currently working on a optional music cog I have added a feature to have a SQL model for this cog where the files to create the tables are in the optional cog's folder and call a function to create/load the tables it needs into the DB.

This would meet the requirements of this issue as the bot is mainly a moderation bot having the SQL models hard coded for the cogs we recommend makes sense and having optional cogs be dynamic as they are not needed to complete this task

Ma-wa-re commented 4 years ago

@Ma-wa-re Look in to using https://alembic.sqlalchemy.org/en/latest/ as suggested by Jason_000 on discord