updated all model declarations so that they represent the database to a T
This commit is contained in:
parent
dcb3afa425
commit
13218ea08b
@ -34,13 +34,13 @@ class Base(DeclarativeBase):
|
||||
return f"{type(self).__name__}({str(self.asdict())})"
|
||||
|
||||
|
||||
# Classes for models with a single column (plus ID) which can be handled by the generic class-based view
|
||||
# Classes for models with a single column (plus ID) which can be handled by the generic class-based view
|
||||
|
||||
class Genre(Base):
|
||||
__tablename__ = 'Genre'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Genre: Mapped[str] = mapped_column(CheckConstraint('Genre <> ""', name='GenreNotEmptyConstraint'), unique=True)
|
||||
Genre: Mapped[str] = mapped_column(CheckConstraint('Genre <> ""', name='GenreNotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
texte: Mapped[List['Text_Genre']] = relationship(back_populates='genre')
|
||||
werke: Mapped[List['Werk_Genre']] = relationship(back_populates='genre')
|
||||
@ -50,7 +50,7 @@ class Herausgeber(Base):
|
||||
__tablename__ = 'Herausgeber'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Name: Mapped[str] = mapped_column(CheckConstraint('Herausgeber <> ""', name='HerausgeberNotEmptyConstraint'), unique=True)
|
||||
Name: Mapped[str] = mapped_column(CheckConstraint('Herausgeber <> ""', name='HerausgeberNotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
werke: Mapped[List['Werk_Herausgeber']] = relationship(back_populates='herausgeber')
|
||||
|
||||
@ -59,7 +59,7 @@ class Pseudonym(Base):
|
||||
__tablename__ = 'Pseudonym'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Pseudonym: Mapped[str] = mapped_column(CheckConstraint('Pseudonym <> ""', name='PseudonymNotEmptyConstraint'), unique=True)
|
||||
Pseudonym: Mapped[str] = mapped_column(CheckConstraint('Pseudonym <> ""', name='PseudonymNotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
veroeffentlichung: Mapped[List['Veroeffentlichung']] = relationship(back_populates='pseudonym')
|
||||
|
||||
@ -68,7 +68,7 @@ class Sprache(Base):
|
||||
__tablename__ = 'Sprache'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Sprache: Mapped[str] = mapped_column(CheckConstraint('Sprache <> ""', name='SpracheNotEmptyConstraint'), unique=True)
|
||||
Sprache: Mapped[str] = mapped_column(CheckConstraint('Sprache <> ""', name='SpracheNotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
text: Mapped[List['Text']] = relationship(back_populates='sprache')
|
||||
|
||||
@ -77,7 +77,7 @@ class Textform(Base):
|
||||
__tablename__ = 'Textform'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Textform: Mapped[str] = mapped_column(CheckConstraint('Textform <> ""', name='TextformNotEmptyConstraint'), unique=True)
|
||||
Textform: Mapped[str] = mapped_column(CheckConstraint('Textform <> ""', name='TextformNotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
text: Mapped[List['Text']] = relationship(back_populates='textform')
|
||||
|
||||
@ -86,7 +86,7 @@ class Verlag(Base):
|
||||
__tablename__ = 'Verlag'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Verlag: Mapped[str] = mapped_column(CheckConstraint('Verlag <> ""', name='VerlagNotEmptyConstraint'), unique=True)
|
||||
Verlag: Mapped[str] = mapped_column(CheckConstraint('Verlag <> ""', name='VerlagNotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
reihe: Mapped[List['Reihe']] = relationship(back_populates='verlag')
|
||||
werk: Mapped[List['Werk']] = relationship(back_populates='verlag')
|
||||
@ -96,18 +96,18 @@ class Werksform(Base):
|
||||
__tablename__ = 'Werksform'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Werksform: Mapped[str] = mapped_column(CheckConstraint('Werksform <> ""', name='WerksformNotEmptyConstraint'), unique=True)
|
||||
Werksform: Mapped[str] = mapped_column(CheckConstraint('Werksform <> ""', name='WerksformNotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
werk: Mapped[List['Werk']] = relationship(back_populates='werksform')
|
||||
|
||||
|
||||
# Classes that have more than one column and need dedicated view functions
|
||||
# Classes that have more than one column and need dedicated view functions
|
||||
|
||||
class Reihe(Base):
|
||||
__tablename__ = 'Reihe'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Titel: Mapped[str] = mapped_column(CheckConstraint('Titel <> ""', name='ReihentitelNotEmptyConstraint'))
|
||||
Titel: Mapped[str] = mapped_column(CheckConstraint('Titel <> ""', name='ReihentitelNotEmptyConstraint'), nullable=False)
|
||||
|
||||
Verlag: Mapped[Optional[str]] = mapped_column(ForeignKey('Verlag.ID'))
|
||||
verlag: Mapped['Verlag'] = relationship(back_populates='reihe')
|
||||
@ -120,14 +120,14 @@ class Titelbild(Base):
|
||||
__tablename__ = 'Titelbild'
|
||||
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Mimetype: Mapped[str]
|
||||
Dateiname: Mapped[str]
|
||||
Dateigroesse: Mapped[int]
|
||||
Breite: Mapped[int]
|
||||
Hoehe: Mapped[int]
|
||||
Bild: Mapped[bytes]
|
||||
Thumbnail: Mapped[bytes]
|
||||
sha256: Mapped[str] = mapped_column(CheckConstraint('sha256 <> ""', name='sha256NotEmptyConstraint'), unique=True)
|
||||
Mimetype: Mapped[str] = mapped_column(nullable=False)
|
||||
Dateiname: Mapped[str] = mapped_column(nullable=False)
|
||||
Dateigroesse: Mapped[int] = mapped_column(nullable=False)
|
||||
Breite: Mapped[int] = mapped_column(nullable=False)
|
||||
Hoehe: Mapped[int] = mapped_column(nullable=False)
|
||||
Bild: Mapped[bytes] = mapped_column(nullable=False)
|
||||
Thumbnail: Mapped[bytes] = mapped_column(nullable=False)
|
||||
sha256: Mapped[str] = mapped_column(CheckConstraint('sha256 <> ""', name='sha256NotEmptyConstraint'), nullable=False, unique=True)
|
||||
|
||||
werk: Mapped[List['Werk']] = relationship(back_populates='titelbild')
|
||||
|
||||
@ -143,15 +143,15 @@ class Text(Base):
|
||||
|
||||
# regular columns
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Titel: Mapped[str] = mapped_column(CheckConstraint('Titel <> ""', name='TexttitelNotEmptyConstraint'))
|
||||
Titel: Mapped[str] = mapped_column(CheckConstraint('Titel <> ""', name='TexttitelNotEmptyConstraint'), nullable=False)
|
||||
Untertitel: Mapped[Optional[str]]
|
||||
|
||||
# many-to-one
|
||||
Reihe: Mapped[Optional[int]] = mapped_column(ForeignKey('Reihe.ID'))
|
||||
reihe: Mapped[Optional["Reihe"]] = relationship(back_populates="text")
|
||||
Sprache: Mapped[int] = mapped_column(ForeignKey('Sprache.ID'))
|
||||
Sprache: Mapped[int] = mapped_column(ForeignKey('Sprache.ID'), nullable=False)
|
||||
sprache: Mapped['Sprache'] = relationship(back_populates='text')
|
||||
Textform: Mapped[int] = mapped_column(ForeignKey('Textform.ID'))
|
||||
Textform: Mapped[int] = mapped_column(ForeignKey('Textform.ID'), nullable=False)
|
||||
textform: Mapped['Textform'] = relationship(back_populates='text')
|
||||
|
||||
# one-to-many
|
||||
@ -167,7 +167,7 @@ class Werk(Base):
|
||||
|
||||
# regular columns
|
||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||
Titel: Mapped[str] = mapped_column(CheckConstraint('Titel <> ""', name='WerkstitelNotEmptyConstraint'))
|
||||
Titel: Mapped[str] = mapped_column(CheckConstraint('Titel <> ""', name='WerkstitelNotEmptyConstraint'), nullable=False)
|
||||
Untertitel: Mapped[Optional[str]]
|
||||
Reihennummer: Mapped[Optional[str]]
|
||||
Erscheinungsdatum: Mapped[Optional[str]]
|
||||
@ -185,7 +185,7 @@ class Werk(Base):
|
||||
titelbild: Mapped[Optional['Titelbild']] = relationship(back_populates='werk')
|
||||
Verlag: Mapped[Optional[int]] = mapped_column(ForeignKey('Verlag.ID'))
|
||||
verlag: Mapped[Optional['Verlag']] = relationship(back_populates='werk')
|
||||
Werksform: Mapped[int] = mapped_column(ForeignKey('Werksform.ID'))
|
||||
Werksform: Mapped[int] = mapped_column(ForeignKey('Werksform.ID'), nullable=False)
|
||||
werksform: Mapped['Werksform'] = relationship(back_populates='werk')
|
||||
|
||||
# one-to-many
|
||||
@ -207,11 +207,11 @@ class Veroeffentlichung(Base):
|
||||
AltUntertitel: Mapped[Optional[str]]
|
||||
|
||||
# many-to-one
|
||||
Pseudonym: Mapped[int] = mapped_column(ForeignKey('Pseudonym.ID'))
|
||||
Pseudonym: Mapped[int] = mapped_column(ForeignKey('Pseudonym.ID'), nullable=False)
|
||||
pseudonym: Mapped['Pseudonym'] = relationship(back_populates='veroeffentlichung')
|
||||
Text: Mapped[int] = mapped_column(ForeignKey('Text.ID'))
|
||||
Text: Mapped[int] = mapped_column(ForeignKey('Text.ID'), nullable=False)
|
||||
text: Mapped['Text'] = relationship(back_populates='veroeffentlichung')
|
||||
Werk: Mapped[int] = mapped_column(ForeignKey('Werk.ID'))
|
||||
Werk: Mapped[int] = mapped_column(ForeignKey('Werk.ID'), nullable=False)
|
||||
werk: Mapped['Werk'] = relationship(back_populates='veroeffentlichung')
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user