CM93 MySQL importer validated baseline
This commit is contained in:
7
scripts/audit_cm93.ps1
Normal file
7
scripts/audit_cm93.ps1
Normal file
@@ -0,0 +1,7 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if (-not (Test-Path ".\.venv\Scripts\cm93db.exe")) {
|
||||
throw "未发现 cm93db,请先运行 scripts\setup_env.ps1"
|
||||
}
|
||||
|
||||
& ".\.venv\Scripts\cm93db.exe" audit @args
|
||||
10
scripts/import_cm93.ps1
Normal file
10
scripts/import_cm93.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if (-not (Test-Path ".\.venv\Scripts\cm93db.exe")) {
|
||||
throw "未发现 cm93db,请先运行 scripts\setup_env.ps1"
|
||||
}
|
||||
if (-not (Test-Path ".env")) {
|
||||
throw "未发现 .env,请从 .env.example 复制并配置 CM93_SOURCE_DIR / MySQL"
|
||||
}
|
||||
|
||||
& ".\.venv\Scripts\cm93db.exe" import @args
|
||||
11
scripts/init_db.ps1
Normal file
11
scripts/init_db.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if (-not (Test-Path ".venv")) {
|
||||
throw "未发现 .venv,请先运行 .\scripts\setup_env.ps1"
|
||||
}
|
||||
if (-not (Test-Path ".env")) {
|
||||
throw "未发现 .env,请从 .env.example 复制并填写数据库信息"
|
||||
}
|
||||
|
||||
& ".\.venv\Scripts\cm93db.exe" db-init --create-database
|
||||
& ".\.venv\Scripts\cm93db.exe" db-check
|
||||
23
scripts/repair_env.ps1
Normal file
23
scripts/repair_env.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Python312 = (pyenv which python | Select-Object -First 1).Trim()
|
||||
if (-not (Test-Path $Python312)) {
|
||||
throw "找不到 pyenv Python: $Python312"
|
||||
}
|
||||
|
||||
$Version = (& $Python312 --version 2>&1).Trim()
|
||||
if ($Version -ne "Python 3.12.10") {
|
||||
throw "pyenv 当前不是 Python 3.12.10: $Version"
|
||||
}
|
||||
|
||||
if (Test-Path ".venv") {
|
||||
Remove-Item -Recurse -Force ".venv"
|
||||
}
|
||||
|
||||
& $Python312 -m venv .venv
|
||||
$VenvPython = (Resolve-Path ".\.venv\Scripts\python.exe").Path
|
||||
& $VenvPython -m pip install --upgrade pip
|
||||
& $VenvPython -m pip install -e .
|
||||
|
||||
& ".\.venv\Scripts\cm93db.exe" --help
|
||||
Write-Host "修复完成。"
|
||||
61
scripts/setup_env.ps1
Normal file
61
scripts/setup_env.ps1
Normal file
@@ -0,0 +1,61 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "[1/6] 设置项目 Python 3.12.10"
|
||||
pyenv local 3.12.10
|
||||
|
||||
Write-Host "[2/6] 通过 pyenv 获取项目 Python"
|
||||
$Python312 = (pyenv which python | Select-Object -First 1).Trim()
|
||||
|
||||
if (-not $Python312) {
|
||||
throw "pyenv which python 未返回 Python 路径"
|
||||
}
|
||||
if (-not (Test-Path $Python312)) {
|
||||
throw "pyenv 返回的 Python 不存在: $Python312"
|
||||
}
|
||||
|
||||
$Version = (& $Python312 --version 2>&1).Trim()
|
||||
Write-Host "Python executable: $Python312"
|
||||
Write-Host "Python version: $Version"
|
||||
|
||||
if ($Version -ne "Python 3.12.10") {
|
||||
throw "项目要求 Python 3.12.10,但 pyenv 当前返回: $Version"
|
||||
}
|
||||
|
||||
Write-Host "[3/6] 检查/创建虚拟环境"
|
||||
if (Test-Path ".venv\Scripts\python.exe") {
|
||||
$ExistingVersion = (& ".\.venv\Scripts\python.exe" --version 2>&1).Trim()
|
||||
if ($ExistingVersion -ne "Python 3.12.10") {
|
||||
Write-Host "发现错误虚拟环境 ($ExistingVersion),正在删除..."
|
||||
Remove-Item -Recurse -Force ".venv"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path ".venv\Scripts\python.exe")) {
|
||||
& $Python312 -m venv .venv
|
||||
}
|
||||
|
||||
$VenvPython = (Resolve-Path ".\.venv\Scripts\python.exe").Path
|
||||
$VenvVersion = (& $VenvPython --version 2>&1).Trim()
|
||||
Write-Host "Venv Python: $VenvVersion"
|
||||
|
||||
if ($VenvVersion -ne "Python 3.12.10") {
|
||||
throw "虚拟环境 Python 版本错误: $VenvVersion"
|
||||
}
|
||||
|
||||
Write-Host "[4/6] 升级 pip"
|
||||
& $VenvPython -m pip install --upgrade pip
|
||||
|
||||
Write-Host "[5/6] 安装项目"
|
||||
& $VenvPython -m pip install -e .
|
||||
|
||||
$Cm93Db = (Resolve-Path ".\.venv\Scripts\cm93db.exe").Path
|
||||
|
||||
Write-Host "[6/6] 基础命令检查"
|
||||
& $Cm93Db --help
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Python 3.12.10 虚拟环境已建立。"
|
||||
Write-Host "下一步:"
|
||||
Write-Host " 1. Copy-Item .env.example .env"
|
||||
Write-Host " 2. 修改 .env 中的 MySQL 5.7.34 参数"
|
||||
Write-Host " 3. .\scripts\init_db.ps1"
|
||||
Reference in New Issue
Block a user