-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Исправить avatar на avatar_id для текущего кода (#146)
В рамках работы над задачами добавления сваггера для профиля (#95), дружбы (#100) и желания (#104), мы предполагали, что файл будет иметь строковый тип и будет представлен ссылкой, поэтому в код сваггера мы добавили его в таком виде: ```python "avatar": "/files/0b928aaa-521f-47ec-8be5-396650e2a187" ``` И схемы для сваггера выглядели соответствующим образом: ```python # src/profile/fields.py: class Avatar(str): """Avatar value field.""" # src/profile/schemas.py: class Profile(Schema): ... # something here avatar: Avatar | None ... # something here ``` Также исходя из этого предположения, во время работы над задачей реализации эндпойнта регистрации (#88) была добавлена колонка `avatar` в модель `Profile` с типом строка: ```python avatar: Mapped[str | None] = mapped_column(String, unique=True) ``` Но после того, как мы начали работать над задачей добавления сваггера для эндпойнтов файла (#108), мы поняли, что вместо строкового типа нам надо использовать uuid в качестве идентификатора файла. Из этого следует, что нам необходимо внести следующие изменения в уже существующий код, описаный выше: - Заменить `avatar` (string) на `avatar_id` (uuid) в существующих схемах и примерах сваггера - Заменить `avatar` (string) на `avatar_id` (uuid) в существующей модели базы данных (`Profile`) В рамках этой задачи необходимо внести изменения, описанные выше. --- **Примечания** Внесения подобных изменений можно было бы избежать, если бы схема для работы с файлами была продумана и добавлена в репозиторий заранее. Т.е. сваггер для эндпойнтов файлов, необходимо было добавить ещё до того, как будет добавлен хоть какой-то сваггер для эндпойнтов приложения, т.к. эндпойнты приложения используют файлы, и необходимо знать заранее как мы планируем работать с файлами. Но поскольку это не было сделано вовремя, то сейчас необходимо внести правки в уже существующий функционал, а так же добавить сваггер для эндпойнтов файла (#108) и реализацию для них этих эндпойнтов, до того как будет добавлен какой-либо новый функционал приложения.
- Loading branch information
1 parent
0b641c6
commit 768108c
Showing
12 changed files
with
65 additions
and
31 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
migrations/versions/2023_11_19_2120-55f1606e7086_change_avatar_to_avatar_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""change avatar to avatar_id | ||
Revision ID: 55f1606e7086 | ||
Revises: d7454b0101c0 | ||
Create Date: 2023-11-19 21:20:01.224200+00:00 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "55f1606e7086" | ||
down_revision = "d7454b0101c0" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("profile", sa.Column("avatar_id", sa.UUID(), nullable=True)) | ||
op.create_unique_constraint("profile_avatar_id_key", "profile", ["avatar_id"]) | ||
|
||
op.drop_constraint("profile_avatar_key", "profile", type_="unique") | ||
op.drop_column("profile", "avatar") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("profile", sa.Column("avatar", sa.VARCHAR(), autoincrement=False, nullable=True)) | ||
op.create_unique_constraint("profile_avatar_key", "profile", ["avatar"]) | ||
|
||
op.drop_constraint("profile_avatar_id_key", "profile", type_="unique") | ||
op.drop_column("profile", "avatar_id") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters