feat: Switch to postgres

Migrate from MariaDB to PostgreSQL.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-11-30 15:13:42 +01:00
parent 4637b2edba
commit fa5dd2ca2c
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
64 changed files with 560 additions and 615 deletions

View file

@ -7,7 +7,7 @@ All functions in this module raise aurweb.exceptions.ValidationError
when encountering invalid criteria and return silently otherwise.
"""
from fastapi import Request
from sqlalchemy import and_
from sqlalchemy import and_, func
from aurweb import aur_logging, config, db, l10n, models, time, util
from aurweb.auth import creds
@ -157,7 +157,11 @@ def username_in_use(
) -> None:
exists = (
db.query(models.User)
.filter(and_(models.User.ID != user.ID, models.User.Username == U))
.filter(
and_(
models.User.ID != user.ID, func.lower(models.User.Username) == U.lower()
)
)
.exists()
)
if db.query(exists).scalar():
@ -175,7 +179,9 @@ def email_in_use(
) -> None:
exists = (
db.query(models.User)
.filter(and_(models.User.ID != user.ID, models.User.Email == E))
.filter(
and_(models.User.ID != user.ID, func.lower(models.User.Email) == E.lower())
)
.exists()
)
if db.query(exists).scalar():