aurweb/aurweb/models/group.py
Kevin Morris 888cf5118a use declarative_base for all ORM models
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>
2021-06-10 13:54:27 -07:00

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"))