diff --git a/src/alembic/versions/2023_11_16_2220-6846ef0ccd9a_.py b/src/alembic/versions/2023_11_16_2220-6846ef0ccd9a_.py new file mode 100644 index 0000000..100ef42 --- /dev/null +++ b/src/alembic/versions/2023_11_16_2220-6846ef0ccd9a_.py @@ -0,0 +1,33 @@ +"""empty message + +Revision ID: 6846ef0ccd9a +Revises: 861f09faff9c +Create Date: 2023-11-16 22:20:36.556485 + +""" +from typing import Sequence, Union + +import sqlalchemy as sa + +from alembic import op + + +# revision identifiers, used by Alembic. +revision: str = "6846ef0ccd9a" +down_revision: Union[str, None] = "861f09faff9c" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column("session", "device_id", existing_type=sa.INTEGER(), nullable=False) + op.add_column("shoe", sa.Column("image_url", sa.String(), nullable=False)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("shoe", "image_url") + op.alter_column("session", "device_id", existing_type=sa.INTEGER(), nullable=True) + # ### end Alembic commands ### diff --git a/src/kb_2315/backend/models/model_shoe.py b/src/kb_2315/backend/models/model_shoe.py index aff8770..29fe327 100644 --- a/src/kb_2315/backend/models/model_shoe.py +++ b/src/kb_2315/backend/models/model_shoe.py @@ -9,5 +9,6 @@ class Shoe(Base): id: Mapped[int] = mapped_column(Integer, primary_key=True) name: Mapped[str] = mapped_column(String, default="Shoe") + image_url: Mapped[str] = mapped_column(String, nullable=True) sessions: Mapped[list[Session]] = relationship("Session", backref="event") diff --git a/src/kb_2315/notify/line.py b/src/kb_2315/notify/line.py index 6ebcd1b..88edd3f 100644 --- a/src/kb_2315/notify/line.py +++ b/src/kb_2315/notify/line.py @@ -34,11 +34,11 @@ def shoe_select_carousel(send_to_id: str = conf.line_group_id, session_id: UUID columns_list: list[CarouselColumn] = [] shoes: list[Shoe] = crud_shoe.search_shoe_by() - for i, shoe in enumerate(shoes): + for shoe in shoes: columns_list.append( CarouselColumn( text=f"靴 {shoe.name}", - thumbnail_image_url=f"https://picsum.photos/200/{300+i}", + thumbnail_image_url=shoe.image_url, actions=[ PostbackAction(label=f"{shoe.name} を選ぶ", data=f"{shoe.id}:{session_id}"), ],