diff --git a/api/alembic/versions/20260506_0017_add_created_at_to_cyoa_audio_and_choice.py b/api/alembic/versions/20260506_0017_add_created_at_to_cyoa_audio_and_choice.py new file mode 100644 index 0000000..3317179 --- /dev/null +++ b/api/alembic/versions/20260506_0017_add_created_at_to_cyoa_audio_and_choice.py @@ -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") \ No newline at end of file diff --git a/api/app/outbound/postgres/entities/adventure_entities.py b/api/app/outbound/postgres/entities/adventure_entities.py index 835c882..1ac2f3c 100644 --- a/api/app/outbound/postgres/entities/adventure_entities.py +++ b/api/app/outbound/postgres/entities/adventure_entities.py @@ -82,6 +82,9 @@ class AdventureEntryPossibleChoiceEntity(Base): index: Mapped[int] = mapped_column(Integer, nullable=False) label: 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): @@ -142,3 +145,6 @@ class AdventureEntryAudioEntity(Base): tts_provider: Mapped[str] = mapped_column(Text, nullable=False, default="google_gemini") tts_options: Mapped[dict | None] = mapped_column(JSONB, nullable=True) 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) + )