generated from john/python-template
@@ -17,6 +17,7 @@ Usage examples:
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
@@ -27,6 +28,7 @@ from transcription.db.migration import export_bundle
|
||||
from transcription.db.migration import import_bundle
|
||||
from transcription.db.migration import migrate_via_bundle
|
||||
from transcription.db.migration import sqlite_url_from_path
|
||||
from transcription.db.migration import verify_migration
|
||||
|
||||
DEFAULT_BUNDLE_DIR: Final[Path] = Path(".migration-bundle")
|
||||
|
||||
@@ -77,6 +79,7 @@ def main() -> int:
|
||||
subparsers.add_parser("export", parents=[common], help="Export DB rows and uploads into bundle")
|
||||
subparsers.add_parser("import", parents=[common], help="Import bundle into target DB and uploads")
|
||||
subparsers.add_parser("migrate", parents=[common], help="Run export then import in one command")
|
||||
subparsers.add_parser("verify", parents=[common], help="Compare source/target row counts and integrity checks")
|
||||
|
||||
args = parser.parse_args()
|
||||
bundle_dir = Path(args.bundle_dir)
|
||||
@@ -104,6 +107,11 @@ def main() -> int:
|
||||
print(f"Import complete: db={target_db_url} uploads={target_upload_dir}")
|
||||
return 0
|
||||
|
||||
if args.command == "verify":
|
||||
report = verify_migration(source_db_url=source_db_url, target_db_url=target_db_url)
|
||||
print(json.dumps(report.to_dict(), indent=2))
|
||||
return 0 if report.success else 1
|
||||
|
||||
migrate_via_bundle(
|
||||
MigrationPaths(
|
||||
source_db_url=source_db_url,
|
||||
|
||||
Reference in New Issue
Block a user