mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
modify schema primary keys to be nullable+defaulted
This fixes SQLAlchemy warnings related to primary keys not having an auto_increment or nullable. We've done this by making all foreign primary keys nullable. In ApiRateLimit's case, we can set a default str to act as a null, which seems a bit more sensible. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
e5df083d45
commit
d7481b9649
5 changed files with 42 additions and 11 deletions
|
@ -1,4 +1,5 @@
|
|||
from sqlalchemy.orm import mapper
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from aurweb.db import make_relationship
|
||||
from aurweb.models.package_base import PackageBase
|
||||
|
@ -10,6 +11,12 @@ class PackageKeyword:
|
|||
PackageBase: PackageBase = None,
|
||||
Keyword: str = None):
|
||||
self.PackageBase = PackageBase
|
||||
if not self.PackageBase:
|
||||
raise IntegrityError(
|
||||
statement="Primary key PackageBaseID cannot be null.",
|
||||
orig="PackageKeywords.PackageBaseID",
|
||||
params=("NULL"))
|
||||
|
||||
self.Keyword = Keyword
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue