mirror of
https://github.com/mindverse/Second-Me.git
synced 2026-07-10 09:48:24 +00:00
* fix: modify thinking_model loading configuration * feat: realize thinkModel ui * feat:store * feat: add combined_llm_config_dto * add thinking_model_config & database migration * directly add thinking model to user_llm_config * delete thinking model repo dto service * delete thinkingmodel table migration * add is_cot config * feat: allow define is_cot * feat: simplify logs info * feat: add training model * feat: fix is_cot problem * fix: fix chat message * fix: fix progress error * fix: disable no settings thinking * feat: add thinking warning * fix: fix start service error * feat:fix init trainparams problem * feat: change playGround prompt * feat: Add Dimension Mismatch Handling for ChromaDB (#157) (#207) * Fix Issue #157 Add chroma_utils.py to manage chromaDB and added docs for explanation * Add logging and debugging process - Enhanced the`reinitialize_chroma_collections` function in`chroma_utils.py` to properly check if collections exist before attempting to delete them, preventing potential errors when collections don't exist. - Improved error handling in the`_handle_dimension_mismatch` method in`embedding_service.py` by adding more robust exception handling and verification steps after reinitialization. - Enhanced the collection initialization process in`embedding_service.py` to provide more detailed error messages and better handle cases where collections still have incorrect dimensions after reinitialization. - Added additional verification steps to ensure that collection dimensions match the expected dimension after creation or retrieval. - Improved logging throughout the code to provide more context in error messages, making debugging easier. * Change topics_generator timeout to 30 (#263) * quick fix * fix: shade -> shade_merge_info (#265) * fix: shade -> shade_merge_info * add convert array * quick fix import error * add log * add heartbeat * new strategy * sse version * add heartbeat * zh to en * optimize code * quick fix convert function * Feat/new branch management (#267) * feat: new branch management * feat: fix multi-upload * optimize contribute management --------- Co-authored-by: Crabboss Mr <1123357821@qq.com> Co-authored-by: Ye Xiangle <yexiangle@mail.mindverse.ai> Co-authored-by: Xinghan Pan <sampan090611@gmail.com> Co-authored-by: doubleBlack2 <108928143+doubleBlack2@users.noreply.github.com> Co-authored-by: kevin-mindverse <kevin@mindverse.ai> Co-authored-by: KKKKKKKevin <115385420+kevin-mindverse@users.noreply.github.com>
88 lines
2.6 KiB
Python
88 lines
2.6 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Database Migration Runner
|
|
|
|
This script runs database migrations using the migration manager.
|
|
It should be executed whenever the database schema needs to be updated.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
project_root = str(Path(__file__).parent.parent)
|
|
sys.path.insert(0, project_root)
|
|
|
|
from lpm_kernel.configs.config import Config
|
|
from lpm_kernel.database.migration_manager import MigrationManager
|
|
|
|
from lpm_kernel.common.logging import logger
|
|
|
|
def get_db_path():
|
|
"""Get the database path from environment or use default"""
|
|
config = Config.from_env()
|
|
db_path = config.get("SQLITE_DB_PATH", os.path.join(project_root, "data", "sqlite", "lpm.db"))
|
|
return db_path
|
|
|
|
def run_migrations():
|
|
"""Run all pending database migrations"""
|
|
db_path = get_db_path()
|
|
|
|
# logger.info(f"Using database at: {db_path}")
|
|
|
|
# Check if database file exists
|
|
if not os.path.exists(db_path):
|
|
# logger.error(f"Database file not found at {db_path}")
|
|
return False
|
|
|
|
try:
|
|
# Initialize migration manager
|
|
migrations_dir = os.path.join(project_root, "lpm_kernel", "database", "migrations")
|
|
manager = MigrationManager(db_path)
|
|
|
|
# Apply migrations
|
|
applied = manager.apply_migrations(migrations_dir)
|
|
|
|
# if applied:
|
|
# logger.info(f"Successfully applied {len(applied)} migrations")
|
|
# else:
|
|
# logger.info("No new migrations to apply")
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error during migrations: {e}")
|
|
return False
|
|
|
|
def create_migration(description):
|
|
"""Create a new migration file"""
|
|
db_path = get_db_path()
|
|
migrations_dir = os.path.join(project_root, "lpm_kernel", "database", "migrations")
|
|
|
|
manager = MigrationManager(db_path)
|
|
filepath = manager.create_migration(description, migrations_dir)
|
|
|
|
# logger.info(f"Created new migration at: {filepath}")
|
|
return filepath
|
|
|
|
if __name__ == "__main__":
|
|
# logger.info("Starting database migration")
|
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == "create":
|
|
if len(sys.argv) > 2:
|
|
description = sys.argv[2]
|
|
create_migration(description)
|
|
else:
|
|
logger.error("Missing migration description")
|
|
print("Usage: python run_migrations.py create 'Add new table'")
|
|
sys.exit(1)
|
|
else:
|
|
success = run_migrations()
|
|
|
|
if success:
|
|
# logger.info("Migration completed successfully")
|
|
sys.exit(0)
|
|
else:
|
|
logger.error("Migration failed")
|
|
sys.exit(1)
|