Feat: migrate script (#14076)

### What problem does this PR solve?

Add command line arguments for mysql config.

### Type of change

- [x] Other (please describe): tool scripts.
This commit is contained in:
Lynn
2026-04-13 20:45:11 +08:00
committed by GitHub
parent 853021ff2a
commit 47d3741dcc
2 changed files with 61 additions and 12 deletions

View File

@@ -795,9 +795,12 @@ Examples:
# List available stages
python mysql_migration.py --list-stages
# Dry run (default - check only, no write)
# Dry run (default - check only, no write) with config file
python mysql_migration.py --stages tenant_model_provider --config /path/to/config.yaml
# Dry run with command line MySQL connection
python mysql_migration.py --stages tenant_model_provider --host localhost --port 3306 --user root --password secret
# Create target tables only (no data migration)
python mysql_migration.py --stages tenant_model_provider --config /path/to/config.yaml --create-table-only
@@ -809,6 +812,18 @@ Examples:
"""
)
# MySQL connection options
parser.add_argument('--host', type=str, default='localhost',
help='MySQL host (default: localhost)')
parser.add_argument('--port', type=int, default=3306,
help='MySQL port (default: 3306)')
parser.add_argument('--user', type=str, default='root',
help='MySQL user (default: root)')
parser.add_argument('--password', type=str, default='',
help='MySQL password (default: empty)')
parser.add_argument('--database', type=str, default='rag_flow',
help='MySQL database name (default: rag_flow)')
# Configuration options
parser.add_argument('--config', '-c', type=str, help='Path to YAML config file')
@@ -834,12 +849,29 @@ Examples:
stages = [s.strip() for s in args.stages.split(',')]
# Load configuration
# Load configuration: command line args take precedence over config file
if args.config:
config = MigrationConfig.from_config_file(args.config)
# Override with command line args if provided
if args.host != 'localhost':
config.host = args.host
if args.port != 3306:
config.port = args.port
if args.user != 'root':
config.user = args.user
if args.password != '':
config.password = args.password
if args.database != 'rag_flow':
config.database = args.database
else:
logging.error("No config file specified. Use --config to specify config file.")
sys.exit(1)
# Use command line args directly
config = MigrationConfig(
host=args.host,
port=args.port,
user=args.user,
password=args.password,
database=args.database
)
logger.info(f"MySQL Configuration: host={config.host}, port={config.port}, "
f"user={config.user}, database={config.database}")