fix: updated folder name to not be the deprecated (#8793)
* Updated folder name to not be the deprecated * Changed backend to use Starter Project as default folder name * Changed docs * Changed frontend to display pure folder name without deprecated * Updated tests * Added migration to change folder name * Refactor migration to rename folder names with unique constraint checks for users. Updated upgrade and downgrade functions to streamline the renaming process for "My Projects" and "Starter Project". --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
parent
d2bee3069b
commit
dc671ae204
13 changed files with 93 additions and 46 deletions
|
|
@ -0,0 +1,75 @@
|
|||
"""Rename default folder
|
||||
|
||||
Revision ID: d9a6ea21edcd
|
||||
Revises: 66f72f04a1de
|
||||
Create Date: 2025-07-02 09:42:46.891585
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
from langflow.utils import migration
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'd9a6ea21edcd'
|
||||
down_revision: Union[str, None] = '66f72f04a1de'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
|
||||
# Check if the folder table exists
|
||||
inspector = sa.inspect(conn)
|
||||
table_names = inspector.get_table_names()
|
||||
|
||||
if "folder" not in table_names:
|
||||
# If folder table doesn't exist, skip this migration
|
||||
return
|
||||
|
||||
# Rename "My Projects" to "Starter Project" only for users who don't already have a "Starter Project" folder
|
||||
# This prevents unique constraint violations
|
||||
update_query = sa.text("""
|
||||
UPDATE folder
|
||||
SET name = 'Starter Project'
|
||||
WHERE name = 'My Projects'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM folder f2
|
||||
WHERE f2.user_id = folder.user_id
|
||||
AND f2.name = 'Starter Project'
|
||||
)
|
||||
""")
|
||||
|
||||
conn.execute(update_query)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
|
||||
# Check if the folder table exists
|
||||
inspector = sa.inspect(conn)
|
||||
table_names = inspector.get_table_names()
|
||||
|
||||
if "folder" not in table_names:
|
||||
# If folder table doesn't exist, skip this migration
|
||||
return
|
||||
|
||||
# Rename "Starter Project" back to "My Projects" only for users who don't already have a "My Projects" folder
|
||||
# This prevents unique constraint violations
|
||||
update_query = sa.text("""
|
||||
UPDATE folder
|
||||
SET name = 'My Projects'
|
||||
WHERE name = 'Starter Project'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM folder f2
|
||||
WHERE f2.user_id = folder.user_id
|
||||
AND f2.name = 'My Projects'
|
||||
)
|
||||
""")
|
||||
|
||||
conn.execute(update_query)
|
||||
|
|
@ -36,7 +36,6 @@ from langflow.base.mcp.util import get_flow_snake_case, get_unique_name, sanitiz
|
|||
from langflow.helpers.flow import json_schema_from_flow
|
||||
from langflow.schema.message import Message
|
||||
from langflow.services.database.models import Flow, Folder
|
||||
from langflow.services.database.models.folder.constants import DEFAULT_FOLDER_NAME, NEW_FOLDER_NAME
|
||||
from langflow.services.deps import get_settings_service, get_storage_service, session_scope
|
||||
from langflow.services.storage.utils import build_content_type_from_extension
|
||||
|
||||
|
|
@ -390,7 +389,6 @@ async def install_mcp_config(
|
|||
logger.debug("Windows detected, using cmd command")
|
||||
|
||||
name = project.name
|
||||
name = NEW_FOLDER_NAME if name == DEFAULT_FOLDER_NAME else name
|
||||
|
||||
# Create the MCP configuration
|
||||
mcp_config = {
|
||||
|
|
@ -517,7 +515,6 @@ async def check_installed_mcp_servers(
|
|||
|
||||
# Project server name pattern (must match the logic in install function)
|
||||
name = project.name
|
||||
name = NEW_FOLDER_NAME if name == DEFAULT_FOLDER_NAME else name
|
||||
project_server_name = f"lf-{sanitize_mcp_name(name)[: (MAX_MCP_SERVER_NAME_LENGTH - 4)]}"
|
||||
|
||||
logger.debug(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
DEFAULT_FOLDER_DESCRIPTION = "Manage your own flows. Download and upload projects."
|
||||
DEFAULT_FOLDER_NAME = "My Projects"
|
||||
NEW_FOLDER_NAME = "Starter Project"
|
||||
DEFAULT_FOLDER_NAME = "Starter Project"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue