Skip to content

SQLModel Migration #853

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e19b742
refactor(database): Initial Guild and GuildConfig SQLModel schemas ad…
anemoijereja-eden May 17, 2025
57b9854
refactor(database): improved readability of new SQLModel Schemas
anemoijereja-eden May 18, 2025
4f69fa4
feat(database): finished writing new guild schemas
anemoijereja-eden May 18, 2025
9405742
feat(database): New SQLModel schemas completed and placed in tux/data…
anemoijereja-eden May 19, 2025
3c5efb8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 19, 2025
eee9029
fix(database): ensure datetime.now calls return UTC
anemoijereja-eden May 19, 2025
f8048d7
chore(poetry.lock): update lockfile
electron271 Jun 5, 2025
e2e81a6
Merge branch 'main' of https://github.com/allthingslinux/tux into sql…
electron271 Jun 20, 2025
0564fcb
delete(main.prisma) i fucking hate git
electron271 Jun 20, 2025
0bb3087
style: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 20, 2025
eea6dad
fix(schemas.py): temporarily add type ignore
electron271 Jun 20, 2025
a493f05
refactor(database): migrate client from Prisma to SQLModel
electron271 Jun 20, 2025
a984037
style: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 20, 2025
8e6818c
fix(base.py): start controller migration
electron271 Jun 22, 2025
b731cb5
feat(db): added alembic
anemoijereja-eden Jun 23, 2025
7092069
fix(controllers): continue controller migration
electron271 Jul 6, 2025
92bdf02
chore(pyproject.toml): update pillow
electron271 Jul 6, 2025
e9ff44e
refactor(moderation): replace prisma.enums.CaseType with tux.database…
electron271 Jul 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Database URLs (Required: one depending on mode)
# The application uses DEV_DATABASE_URL when run with '--dev' flag,
# and PROD_DATABASE_URL otherwise (production mode).
# PREFIX SHOULD BE postgresql+asyncpg://"
DEV_DATABASE_URL=""
PROD_DATABASE_URL=""

Expand Down
555 changes: 420 additions & 135 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions prisma/schema/commands/afk.prisma

This file was deleted.

60 changes: 0 additions & 60 deletions prisma/schema/commands/moderation.prisma

This file was deleted.

14 changes: 0 additions & 14 deletions prisma/schema/commands/reminder.prisma

This file was deleted.

15 changes: 0 additions & 15 deletions prisma/schema/commands/snippets.prisma

This file was deleted.

28 changes: 0 additions & 28 deletions prisma/schema/guild/config.prisma

This file was deleted.

16 changes: 0 additions & 16 deletions prisma/schema/guild/guild.prisma

This file was deleted.

13 changes: 0 additions & 13 deletions prisma/schema/guild/levels.prisma

This file was deleted.

25 changes: 0 additions & 25 deletions prisma/schema/guild/starboard.prisma

This file was deleted.

12 changes: 0 additions & 12 deletions prisma/schema/main.prisma

This file was deleted.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ githubkit = { version = ">=0.12.0", extras = ["auth-app"] }
httpx = ">=0.28.0"
jishaku = ">=2.5.2"
loguru = ">=0.7.2"
pillow = ">=11.2.1,<11.3.0"
prisma = ">=0.15.0"
pillow = ">=11.3.0,<11.4.0"
psutil = ">=6.0.0"
pynacl = ">=1.5.0"
python-dotenv = ">=1.0.1"
Expand All @@ -52,6 +51,9 @@ arrow = "^1.3.0"
click = "^8.1.8"
levenshtein = "^0.27.1"
jinja2 = "^3.1.6"
sqlmodel = "^0.0.24"
asyncpg = "^0.30.0"
alembic = "^1.16.2"

[tool.poetry.group.dev.dependencies]
pre-commit = "==4.2.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tux/utils/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from prisma.models import Case
from tux.database.schemas import Case
from tux.utils.exceptions import (
APIConnectionError,
APIRequestError,
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from discord.ext import commands
from loguru import logger

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.controllers import DatabaseController
from tux.database.schemas import CaseType
from tux.ui.embeds import EmbedCreator, EmbedType
from tux.utils.constants import CONST
from tux.utils.exceptions import handle_case_result, handle_gather_result
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/ban.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import BanFlags
from tux.utils.functions import generate_usage
Expand Down
6 changes: 2 additions & 4 deletions tux/cogs/moderation/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from loguru import logger
from reactionmenu import ViewButton, ViewMenu

from prisma.enums import CaseType
from prisma.models import Case
from prisma.types import CaseWhereInput
from tux.bot import Tux
from tux.database.schemas import Case, CaseType
from tux.ui.embeds import EmbedCreator, EmbedType
from tux.utils import checks
from tux.utils.constants import CONST
Expand Down Expand Up @@ -246,7 +244,7 @@ async def _view_cases_with_flags(
"""
assert ctx.guild

options: CaseWhereInput = {}
options: dict[str, Any] = {}

if flags.type:
options["case_type"] = flags.type
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from discord.ext import commands
from loguru import logger

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import JailFlags
from tux.utils.functions import generate_usage
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/kick.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import KickFlags
from tux.utils.functions import generate_usage
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/pollban.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import PollBanFlags
from tux.utils.functions import generate_usage
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/pollunban.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import PollUnbanFlags
from tux.utils.functions import generate_usage
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/snippetban.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import SnippetBanFlags
from tux.utils.functions import generate_usage
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/snippetunban.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import SnippetUnbanFlags
from tux.utils.functions import generate_usage
Expand Down
3 changes: 1 addition & 2 deletions tux/cogs/moderation/tempban.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from discord.ext import commands, tasks
from loguru import logger

from prisma.enums import CaseType
from prisma.models import Case
from tux.bot import Tux
from tux.database.schemas import Case, CaseType
from tux.utils import checks
from tux.utils.flags import TempBanFlags
from tux.utils.functions import generate_usage
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import TimeoutFlags
from tux.utils.functions import generate_usage, parse_time_string
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/unban.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.constants import CONST
from tux.utils.flags import UnbanFlags
Expand Down
3 changes: 1 addition & 2 deletions tux/cogs/moderation/unjail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from discord.ext import commands
from loguru import logger

from prisma.enums import CaseType
from prisma.models import Case
from tux.bot import Tux
from tux.database.schemas import Case, CaseType
from tux.utils import checks
from tux.utils.flags import UnjailFlags
from tux.utils.functions import generate_usage
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/untimeout.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

from prisma.enums import CaseType
from tux.bot import Tux
from tux.database.schemas import CaseType
from tux.utils import checks
from tux.utils.flags import UntimeoutFlags
from tux.utils.functions import generate_usage
Expand Down
Loading