Second-Me/scripts/downgrade_migration.py
ryangyuan 9fe511f0f2
Feature/0416/add thinking mode (#264)
* 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>
2025-04-24 14:19:23 +08:00

64 lines
1.8 KiB
Python

#!/usr/bin/env python
"""
Database Migration Downgrade Tool
Usage:
python downgrade_migration.py [version]
Arguments:
version: Optional, version to downgrade to (inclusive).
If not provided, all migrations will be downgraded.
"""
import os
import sys
import sqlite3
import importlib.util
from pathlib import Path
# Add project root to Python path
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, project_root)
# Import migration manager
from lpm_kernel.database.migration_manager import MigrationManager
from lpm_kernel.configs.config import Config
def main():
# Get database path
config = Config.from_env()
db_path = config.database.db_file
print(f"Database path: {db_path}")
# Create migration manager
manager = MigrationManager(db_path)
# Get applied migrations
applied = manager.get_applied_migrations()
print(f"Applied migrations: {', '.join(applied) if applied else 'none'}")
if not applied:
print("No migrations to downgrade")
return
# Check command line arguments
if len(sys.argv) > 1:
target_version = sys.argv[1]
if target_version not in applied:
print(f"Error: Version {target_version} is not applied, cannot downgrade to this version")
return
print(f"Downgrading to version {target_version}...")
downgraded = manager.downgrade_to_version(target_version)
else:
print("Downgrading all migrations...")
downgraded = manager.downgrade_to_version()
if downgraded:
print(f"Successfully downgraded migrations: {', '.join(downgraded)}")
else:
print("No migrations were downgraded")
if __name__ == "__main__":
main()