From 04544b172f5482ffba36e05cf7a0e84125998eef Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 8 Sep 2023 07:36:56 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat(alembic):=20add=20migration?= =?UTF-8?q?=20to=20add=20profile=5Fimage=20column=20to=20user=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 chore(user.py): add profile_image field to User model for storing user profile images --- .../67cc006d50bf_add_profile_image_column.py | 39 +++++++++++++++++++ .../services/database/models/user/user.py | 2 + 2 files changed, 41 insertions(+) create mode 100644 src/backend/langflow/alembic/versions/67cc006d50bf_add_profile_image_column.py diff --git a/src/backend/langflow/alembic/versions/67cc006d50bf_add_profile_image_column.py b/src/backend/langflow/alembic/versions/67cc006d50bf_add_profile_image_column.py new file mode 100644 index 000000000..5a3cbc448 --- /dev/null +++ b/src/backend/langflow/alembic/versions/67cc006d50bf_add_profile_image_column.py @@ -0,0 +1,39 @@ +"""Add profile-image column + +Revision ID: 67cc006d50bf +Revises: 260dbcc8b680 +Create Date: 2023-09-08 07:36:13.387318 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +import sqlmodel + + +# revision identifiers, used by Alembic. +revision: str = "67cc006d50bf" +down_revision: Union[str, None] = "260dbcc8b680" +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! ### + with op.batch_alter_table("user", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "profile_image", sqlmodel.sql.sqltypes.AutoString(), nullable=True + ) + ) + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("user", schema=None) as batch_op: + batch_op.drop_column("profile_image") + + # ### end Alembic commands ### diff --git a/src/backend/langflow/services/database/models/user/user.py b/src/backend/langflow/services/database/models/user/user.py index b58f7226a..105f6281b 100644 --- a/src/backend/langflow/services/database/models/user/user.py +++ b/src/backend/langflow/services/database/models/user/user.py @@ -15,6 +15,7 @@ class User(SQLModelSerializable, table=True): id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True) username: str = Field(index=True, unique=True) password: str = Field() + profile_image: Optional[str] = Field(default=None) is_active: bool = Field(default=False) is_superuser: bool = Field(default=False) create_at: datetime = Field(default_factory=datetime.utcnow) @@ -40,6 +41,7 @@ class UserRead(SQLModel): class UserUpdate(SQLModel): + profile_image: Optional[str] = Field() password: Optional[str] = Field() is_active: Optional[bool] = Field() is_superuser: Optional[bool] = Field()