mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
This rewrites the entire model base as declarative models. This allows us to more easily customize overlay fields in tables and is more common. This effort also brought some DB violations to light which this commit addresses. Signed-off-by: Kevin Morris <kevr@0cost.org>
20 lines
518 B
Python
20 lines
518 B
Python
from sqlalchemy import Column, Integer
|
|
from sqlalchemy.exc import IntegrityError
|
|
|
|
from aurweb.models.declarative import Base
|
|
|
|
|
|
class Group(Base):
|
|
__tablename__ = "Groups"
|
|
|
|
ID = Column(Integer, primary_key=True)
|
|
|
|
__mapper_args__ = {"primary_key": [ID]}
|
|
|
|
def __init__(self, Name: str = None):
|
|
self.Name = Name
|
|
if not self.Name:
|
|
raise IntegrityError(
|
|
statement="Column Name cannot be null.",
|
|
orig="Groups.Name",
|
|
params=("NULL"))
|