split files, database and S3, models
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import uuid
|
||||
from sqlalchemy import Column, String, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from .database import Base
|
||||
|
||||
class Project(Base):
|
||||
__tablename__ = "projects"
|
||||
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
name = Column(String, nullable=False)
|
||||
# 级联删除
|
||||
markdowns = relationship("Markdown", back_populates="project", cascade="all, delete-orphan")
|
||||
|
||||
class Markdown(Base):
|
||||
__tablename__ = "markdowns"
|
||||
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
title = Column(String, nullable=False)
|
||||
s3_key = Column(String, nullable=False)
|
||||
project_id = Column(String, ForeignKey("projects.id", ondelete="CASCADE"))
|
||||
project = relationship("Project", back_populates="markdowns")
|
||||
Reference in New Issue
Block a user