feat: [api] add created timestamps to adventure entities
This commit is contained in:
parent
461473d379
commit
d54f98d007
2 changed files with 48 additions and 0 deletions
|
|
@ -0,0 +1,42 @@
|
||||||
|
"""add created_at to cyoa audio and possible choice
|
||||||
|
|
||||||
|
Revision ID: 0017
|
||||||
|
Revises: 0016
|
||||||
|
Create Date: 2026-05-06
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
revision: str = "0017"
|
||||||
|
down_revision: Union[str, None] = "0016"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
op.add_column(
|
||||||
|
"choose_your_own_adventure_entry_audio",
|
||||||
|
sa.Column(
|
||||||
|
"created_at",
|
||||||
|
sa.DateTime(timezone=True),
|
||||||
|
nullable=False,
|
||||||
|
server_default=sa.func.now(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
op.add_column(
|
||||||
|
"choose_your_own_adventure_entry_possible_choice",
|
||||||
|
sa.Column(
|
||||||
|
"created_at",
|
||||||
|
sa.DateTime(timezone=True),
|
||||||
|
nullable=False,
|
||||||
|
server_default=sa.func.now(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
op.drop_column("choose_your_own_adventure_entry_possible_choice", "created_at")
|
||||||
|
op.drop_column("choose_your_own_adventure_entry_audio", "created_at")
|
||||||
|
|
@ -82,6 +82,9 @@ class AdventureEntryPossibleChoiceEntity(Base):
|
||||||
index: Mapped[int] = mapped_column(Integer, nullable=False)
|
index: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
label: Mapped[str] = mapped_column(Text, nullable=False)
|
label: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
text: Mapped[str] = mapped_column(Text, nullable=False)
|
text: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True), nullable=False, default=lambda: datetime.now(timezone.utc)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AdventureEntryPossibleChoiceDecisionEntity(Base):
|
class AdventureEntryPossibleChoiceDecisionEntity(Base):
|
||||||
|
|
@ -142,3 +145,6 @@ class AdventureEntryAudioEntity(Base):
|
||||||
tts_provider: Mapped[str] = mapped_column(Text, nullable=False, default="google_gemini")
|
tts_provider: Mapped[str] = mapped_column(Text, nullable=False, default="google_gemini")
|
||||||
tts_options: Mapped[dict | None] = mapped_column(JSONB, nullable=True)
|
tts_options: Mapped[dict | None] = mapped_column(JSONB, nullable=True)
|
||||||
file_name: Mapped[str] = mapped_column(Text, nullable=False)
|
file_name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True), nullable=False, default=lambda: datetime.now(timezone.utc)
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue