mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
22d1a8b6c3
- Removed mount_commands.py (mount functionality deprecated) - Removed BISYNC_PROFILES and all tenant-wide bisync functions - Removed bisync_config from config schema - Simplified core_commands.py setup command (project-scoped workflow) - Removed top-level sync command (confusing in cloud mode, automatic in local mode) - Updated db.py to use run_sync() directly instead of sync command - Cleaned up unused imports throughout All operations now project-scoped via: bm project bisync --name <project> bm project sync --name <project> bm project check --name <project> Signed-off-by: phernandez <paul@basicmachines.co>
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
"""Database management commands."""
|
|
|
|
import asyncio
|
|
|
|
import typer
|
|
from loguru import logger
|
|
|
|
from basic_memory import db
|
|
from basic_memory.cli.app import app
|
|
from basic_memory.config import ConfigManager, BasicMemoryConfig, save_basic_memory_config
|
|
|
|
|
|
@app.command()
|
|
def reset(
|
|
reindex: bool = typer.Option(False, "--reindex", help="Rebuild db index from filesystem"),
|
|
): # pragma: no cover
|
|
"""Reset database (drop all tables and recreate)."""
|
|
if typer.confirm("This will delete all data in your db. Are you sure?"):
|
|
logger.info("Resetting database...")
|
|
config_manager = ConfigManager()
|
|
app_config = config_manager.config
|
|
# Get database path
|
|
db_path = app_config.app_database_path
|
|
|
|
# Delete the database file if it exists
|
|
if db_path.exists():
|
|
db_path.unlink()
|
|
logger.info(f"Database file deleted: {db_path}")
|
|
|
|
# Reset project configuration
|
|
config = BasicMemoryConfig()
|
|
save_basic_memory_config(config_manager.config_file, config)
|
|
logger.info("Project configuration reset to default")
|
|
|
|
# Create a new empty database
|
|
asyncio.run(db.run_migrations(app_config))
|
|
logger.info("Database reset complete")
|
|
|
|
if reindex:
|
|
# Run database sync directly
|
|
from basic_memory.cli.commands.command_utils import run_sync
|
|
|
|
logger.info("Rebuilding search index from filesystem...")
|
|
asyncio.run(run_sync(project=None))
|