-
Notifications
You must be signed in to change notification settings - Fork 9
Feature: Database #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit also cleans up redundant imports in `config.py` and fixes some type hints.
This function is ran before the discord modmail bot is ran so that the bot is not ran unnecessarily even if the DB is not responding. It creates a local session which can be used throughout the bot and then tests if the db is responding. If the DB is not responding it would log the error with the exception and then exit, it doesn't raise the exception as the the sqlalchemy connection errors are usually really long and maybe "spammy", to reduce the logs down it just logs down the error and then exists silently.
Since we are getting the embed json content directly via discord.py's embed and not generating or touching it, we are safe and validation shouldn't be needed. I have made an extra commit here, in case we ever need it again in future we won't need to rewrite it all over again.
Because it stores things not in the messages/tickets, and it's just use to refer to the message the thread starts from in the ticket logging channel. https://discord.com/channels/798235512208490526/845824657306288158/881136355348992060
Assert statements are removed when running in optimized mode, but we don't.
1689e39 to
945af5d
Compare
|
Removed Shivansh as he's busy, @bast0006 is hopefully going to finish this pr. |
Codecov Report
@@ Coverage Diff @@
## main #65 +/- ##
==========================================
- Coverage 38.62% 32.92% -5.70%
==========================================
Files 16 27 +11
Lines 769 902 +133
Branches 105 110 +5
==========================================
Hits 297 297
- Misses 459 590 +131
- Partials 13 15 +2
Continue to review full report at Codecov.
|
|
Closing this, as I would be rewriting it using tortoise ORM. |
Closes #55
This PR adds an async PostgreSQL setup with the help of SQLAlchemy and alembic. Alembic
is a tool for keeping track of the database migration history and SQLAlchemy(with asyncpg) is a popular ORM tool. The following models have been added to the DB:
Where the
EmbedsandAttachmentsare foreign keys to theMessages.idcolumn.TODO
Docker support(deffered)