feat: add full project - backend, frontend, docker, specs and configs
This commit is contained in:
parent
b77c7d5a01
commit
e6cb06255b
24489 changed files with 61341 additions and 36 deletions
33
backend/app/models/saved_property.py
Normal file
33
backend/app/models/saved_property.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import uuid
|
||||
from datetime import datetime
|
||||
from app.extensions import db
|
||||
|
||||
|
||||
class SavedProperty(db.Model):
|
||||
__tablename__ = "saved_properties"
|
||||
|
||||
id = db.Column(db.String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
user_id = db.Column(
|
||||
db.String(36),
|
||||
db.ForeignKey("client_users.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
property_id = db.Column(
|
||||
db.UUID(as_uuid=True),
|
||||
db.ForeignKey("properties.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint(
|
||||
"user_id", "property_id", name="uq_saved_properties_user_property"
|
||||
),
|
||||
)
|
||||
|
||||
user = db.relationship(
|
||||
"ClientUser", backref=db.backref("saved_properties", lazy="joined")
|
||||
)
|
||||
property = db.relationship("Property", foreign_keys=[property_id], lazy="joined")
|
||||
Loading…
Add table
Add a link
Reference in a new issue