-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Problem in the description field when using the MariaDB or MySQL (…
…#3431) * fix: Problem in the description field when using the MariaDB or MySQL database. * fix: Problem in the description field when using the MariaDB or MySQL database. * fix: Add the migration script to update description columns type. * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/alembic/versions/1d90f8a0efe1_update_description_columns_type.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> --------- Co-authored-by: Marcelo Nunes <marcelo.nunes@nava.com.br> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
- Loading branch information
1 parent
06ea6c4
commit 10d0336
Showing
3 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/backend/base/langflow/alembic/versions/1d90f8a0efe1_update_description_columns_type.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,70 @@ | ||
"""Update description columns type | ||
Revision ID: 4522eb831f5c | ||
Revises: 0d60fcbd4e8e | ||
Create Date: 2024-08-20 11:46:56.266061 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from langflow.utils import migration | ||
from sqlalchemy.engine.reflection import Inspector | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "4522eb831f5c" | ||
down_revision: Union[str, None] = "0d60fcbd4e8e" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
conn = op.get_bind() | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
inspector = Inspector.from_engine(conn) # type: ignore | ||
|
||
with op.batch_alter_table("flow", schema=None) as batch_op: | ||
if migration.column_exists(table_name="flow", column_name="description", conn=conn): | ||
columns = inspector.get_columns("flow") | ||
description_column = next((column for column in columns if column["name"] == "description"), None) | ||
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR): | ||
batch_op.alter_column( | ||
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True | ||
) | ||
|
||
with op.batch_alter_table("folder", schema=None) as batch_op: | ||
if migration.column_exists(table_name="folder", column_name="description", conn=conn): | ||
columns = inspector.get_columns("folder") | ||
description_column = next((column for column in columns if column["name"] == "description"), None) | ||
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR): | ||
batch_op.alter_column( | ||
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
conn = op.get_bind() | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
inspector = Inspector.from_engine(conn) # type: ignore | ||
with op.batch_alter_table("folder", schema=None) as batch_op: | ||
if migration.column_exists(table_name="folder", column_name="description", conn=conn): | ||
columns = inspector.get_columns("folder") | ||
description_column = next((column for column in columns if column["name"] == "description"), None) | ||
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR): | ||
batch_op.alter_column( | ||
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True | ||
) | ||
|
||
with op.batch_alter_table("flow", schema=None) as batch_op: | ||
if migration.column_exists(table_name="flow", column_name="description", conn=conn): | ||
columns = inspector.get_columns("flow") | ||
description_column = next((column for column in columns if column["name"] == "description"), None) | ||
if description_column is not None and isinstance(description_column["type"], sa.VARCHAR): | ||
batch_op.alter_column( | ||
"description", existing_type=sa.VARCHAR(), type_=sa.Text(), existing_nullable=True | ||
) | ||
# ### 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