mirror of
https://git.victorphan.net/basketballcantho/ten-project.git
synced 2026-08-05 13:03:10 +07:00
hoàn thành tính năng mp3 player
This commit is contained in:
@@ -10,6 +10,7 @@ from sqlalchemy import (
|
||||
ForeignKey,
|
||||
DateTime,
|
||||
UniqueConstraint,
|
||||
Boolean,
|
||||
)
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import relationship
|
||||
@@ -57,6 +58,7 @@ class PDF(Base):
|
||||
# Relationships
|
||||
owner = relationship("User", back_populates="pdfs")
|
||||
annotations = relationship("Annotation", back_populates="pdf", cascade="all, delete-orphan")
|
||||
audio_tracks = relationship("PDFAudio", back_populates="pdf", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class Annotation(Base):
|
||||
@@ -81,3 +83,18 @@ class Annotation(Base):
|
||||
# Relationships
|
||||
pdf = relationship("PDF", back_populates="annotations")
|
||||
owner = relationship("User", back_populates="annotations")
|
||||
|
||||
|
||||
class PDFAudio(Base):
|
||||
__tablename__ = "pdf_audios"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
pdf_id = Column(Integer, ForeignKey("pdfs.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
file_path = Column(Text, nullable=False)
|
||||
track_name = Column(String(255), nullable=False)
|
||||
page_number = Column(Integer, nullable=True) # optional: link to a specific page
|
||||
sort_order = Column(Integer, nullable=False, default=1)
|
||||
created_at = Column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), nullable=False)
|
||||
|
||||
# Relationships
|
||||
pdf = relationship("PDF", back_populates="audio_tracks")
|
||||
|
||||
Reference in New Issue
Block a user