Adding soft-delete support.
This commit is contained in:
parent
59bc92d767
commit
909f20f207
3 changed files with 61 additions and 8 deletions
23
muck/models/dbref.py
Normal file
23
muck/models/dbref.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from crudkit.core.base import CRUDMixin, Base
|
||||
|
||||
class Dbref(Base, CRUDMixin):
|
||||
__tablename__ = "dbref"
|
||||
|
||||
type = Column(String, nullable=False)
|
||||
name = Column(String, nullable=False)
|
||||
|
||||
owner_id = Column(Integer, ForeignKey("dbref.id"))
|
||||
location_id = Column(Integer, ForeignKey("dbref.id"))
|
||||
|
||||
owner = relationship("Dbref", remote_side=[CRUDMixin.id], foreign_keys=[owner_id])
|
||||
location = relationship("Dbref", remote_side=[CRUDMixin.id], foreign_keys=[location_id])
|
||||
|
||||
__mapper_args__ = {
|
||||
"polymorphic_on": type,
|
||||
"polymorphic_identity": "dbref"
|
||||
}
|
||||
|
||||
def __str__(self):
|
||||
return f"#{self.id} ({self.type}): {self.name}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue