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())})"
|
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):
|
class Genre(Base):
|
||||||
__tablename__ = 'Genre'
|
__tablename__ = 'Genre'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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')
|
texte: Mapped[List['Text_Genre']] = relationship(back_populates='genre')
|
||||||
werke: Mapped[List['Werk_Genre']] = relationship(back_populates='genre')
|
werke: Mapped[List['Werk_Genre']] = relationship(back_populates='genre')
|
||||||
@ -50,7 +50,7 @@ class Herausgeber(Base):
|
|||||||
__tablename__ = 'Herausgeber'
|
__tablename__ = 'Herausgeber'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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')
|
werke: Mapped[List['Werk_Herausgeber']] = relationship(back_populates='herausgeber')
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class Pseudonym(Base):
|
|||||||
__tablename__ = 'Pseudonym'
|
__tablename__ = 'Pseudonym'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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')
|
veroeffentlichung: Mapped[List['Veroeffentlichung']] = relationship(back_populates='pseudonym')
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class Sprache(Base):
|
|||||||
__tablename__ = 'Sprache'
|
__tablename__ = 'Sprache'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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')
|
text: Mapped[List['Text']] = relationship(back_populates='sprache')
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class Textform(Base):
|
|||||||
__tablename__ = 'Textform'
|
__tablename__ = 'Textform'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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')
|
text: Mapped[List['Text']] = relationship(back_populates='textform')
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class Verlag(Base):
|
|||||||
__tablename__ = 'Verlag'
|
__tablename__ = 'Verlag'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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')
|
reihe: Mapped[List['Reihe']] = relationship(back_populates='verlag')
|
||||||
werk: Mapped[List['Werk']] = relationship(back_populates='verlag')
|
werk: Mapped[List['Werk']] = relationship(back_populates='verlag')
|
||||||
@ -96,18 +96,18 @@ class Werksform(Base):
|
|||||||
__tablename__ = 'Werksform'
|
__tablename__ = 'Werksform'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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')
|
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):
|
class Reihe(Base):
|
||||||
__tablename__ = 'Reihe'
|
__tablename__ = 'Reihe'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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[Optional[str]] = mapped_column(ForeignKey('Verlag.ID'))
|
||||||
verlag: Mapped['Verlag'] = relationship(back_populates='reihe')
|
verlag: Mapped['Verlag'] = relationship(back_populates='reihe')
|
||||||
@ -120,14 +120,14 @@ class Titelbild(Base):
|
|||||||
__tablename__ = 'Titelbild'
|
__tablename__ = 'Titelbild'
|
||||||
|
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
ID: Mapped[int] = mapped_column(primary_key=True)
|
||||||
Mimetype: Mapped[str]
|
Mimetype: Mapped[str] = mapped_column(nullable=False)
|
||||||
Dateiname: Mapped[str]
|
Dateiname: Mapped[str] = mapped_column(nullable=False)
|
||||||
Dateigroesse: Mapped[int]
|
Dateigroesse: Mapped[int] = mapped_column(nullable=False)
|
||||||
Breite: Mapped[int]
|
Breite: Mapped[int] = mapped_column(nullable=False)
|
||||||
Hoehe: Mapped[int]
|
Hoehe: Mapped[int] = mapped_column(nullable=False)
|
||||||
Bild: Mapped[bytes]
|
Bild: Mapped[bytes] = mapped_column(nullable=False)
|
||||||
Thumbnail: Mapped[bytes]
|
Thumbnail: Mapped[bytes] = mapped_column(nullable=False)
|
||||||
sha256: Mapped[str] = mapped_column(CheckConstraint('sha256 <> ""', name='sha256NotEmptyConstraint'), unique=True)
|
sha256: Mapped[str] = mapped_column(CheckConstraint('sha256 <> ""', name='sha256NotEmptyConstraint'), nullable=False, unique=True)
|
||||||
|
|
||||||
werk: Mapped[List['Werk']] = relationship(back_populates='titelbild')
|
werk: Mapped[List['Werk']] = relationship(back_populates='titelbild')
|
||||||
|
|
||||||
@ -143,15 +143,15 @@ class Text(Base):
|
|||||||
|
|
||||||
# regular columns
|
# regular columns
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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]]
|
Untertitel: Mapped[Optional[str]]
|
||||||
|
|
||||||
# many-to-one
|
# many-to-one
|
||||||
Reihe: Mapped[Optional[int]] = mapped_column(ForeignKey('Reihe.ID'))
|
Reihe: Mapped[Optional[int]] = mapped_column(ForeignKey('Reihe.ID'))
|
||||||
reihe: Mapped[Optional["Reihe"]] = relationship(back_populates="text")
|
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')
|
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')
|
textform: Mapped['Textform'] = relationship(back_populates='text')
|
||||||
|
|
||||||
# one-to-many
|
# one-to-many
|
||||||
@ -167,7 +167,7 @@ class Werk(Base):
|
|||||||
|
|
||||||
# regular columns
|
# regular columns
|
||||||
ID: Mapped[int] = mapped_column(primary_key=True)
|
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]]
|
Untertitel: Mapped[Optional[str]]
|
||||||
Reihennummer: Mapped[Optional[str]]
|
Reihennummer: Mapped[Optional[str]]
|
||||||
Erscheinungsdatum: Mapped[Optional[str]]
|
Erscheinungsdatum: Mapped[Optional[str]]
|
||||||
@ -185,7 +185,7 @@ class Werk(Base):
|
|||||||
titelbild: Mapped[Optional['Titelbild']] = relationship(back_populates='werk')
|
titelbild: Mapped[Optional['Titelbild']] = relationship(back_populates='werk')
|
||||||
Verlag: Mapped[Optional[int]] = mapped_column(ForeignKey('Verlag.ID'))
|
Verlag: Mapped[Optional[int]] = mapped_column(ForeignKey('Verlag.ID'))
|
||||||
verlag: Mapped[Optional['Verlag']] = relationship(back_populates='werk')
|
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')
|
werksform: Mapped['Werksform'] = relationship(back_populates='werk')
|
||||||
|
|
||||||
# one-to-many
|
# one-to-many
|
||||||
@ -207,11 +207,11 @@ class Veroeffentlichung(Base):
|
|||||||
AltUntertitel: Mapped[Optional[str]]
|
AltUntertitel: Mapped[Optional[str]]
|
||||||
|
|
||||||
# many-to-one
|
# 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')
|
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')
|
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')
|
werk: Mapped['Werk'] = relationship(back_populates='veroeffentlichung')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user